Skip to content
This repository was archived by the owner on Mar 24, 2020. It is now read-only.

Commit c9f3cf8

Browse files
VivianChumcritchlow
authored andcommitted
Add title attribute to image tag
1 parent 14c76be commit c9f3cf8

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

app/assets/javascripts/views-object.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ dp.cartographics = {}; // CARTOGRAPHICS DISPLAY
123123
switch(fileType)
124124
{
125125
case "image":
126-
$(container).html( '<a href="'+serviceFilePath+'" alt=""><img alt="' + alt_txt + '" src="'+displayFilePath+'"></a>' );
126+
$(container).html( '<a href="'+serviceFilePath+'" alt=""><img alt="' + alt_txt + '" title="' + alt_txt + '" src="'+displayFilePath+'"></a>' );
127127
break;
128128
case "audio":
129129
jwplayer("dams-audio-"+componentIndex).setup({

app/views/dams_collections/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<div class="hidden-phone">
4747
<%# Collection image %>
4848
<div id="collections-image" class="hidden-phone">
49-
<img src="/assets/dams/collections/img/<%=@document['id']%>.jpg" alt="<%=alt_tag_text(@collection_title)%>">
49+
<img src="/assets/dams/collections/img/<%=@document['id']%>.jpg" alt="<%=alt_tag_text(@collection_title)%>" title="<%=alt_tag_text(@collection_title)%>">
5050
</div>
5151
<%# Collection controls %>
5252
<% if @object_count > 0 %>

app/views/dams_objects/_image_viewer.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
alt_txt = alt_tag_text(@page_title)
88
%>
99
<% if displayFilePath.length > 0 && getFilesType != "PDF"%>
10-
<%= link_to image_tag(displayFilePath, :alt => "#{alt_txt}"), zoomFilePath %>
10+
<%= link_to image_tag(displayFilePath, :alt => "#{alt_txt}", :title => "#{alt_txt}"), zoomFilePath %>
1111
<% else %>
1212
<% if getFilesType == "PDF" %>
1313
<% if displayFilePath.to_s == ''%>
1414
<%= render :partial => 'metadata_data_file', :locals => {:fileName => filePath} %>
1515
<% else %>
16-
<%= link_to image_tag(displayFilePath, :alt => "#{alt_txt}"), zoomFilePath %>
16+
<%= link_to image_tag(displayFilePath, :alt => "#{alt_txt}", :title => "#{alt_txt}"), zoomFilePath %>
1717
<%= render :partial => 'metadata_data_file', :locals => {:fileName => service_file} %>
1818
<% end %>
1919
<%= render :partial => 'data_viewer', :locals => {:filePath => pdfFilePath, :objectType => 'simple', :displayFilePath => displayFilePath} %>
2020
<% else %>
21-
<%= link_to image_tag(filePath, :alt => "#{alt_txt}"), zoomFilePath %>
21+
<%= link_to image_tag(filePath, :alt => "#{alt_txt}", :title => "#{alt_txt}"), zoomFilePath %>
2222
<% end %>
2323
<% end %>
2424
<%= render :partial => 'admin_download', :locals => {:embedURL => embed_url, :downloadFilePath => downloadFilePath, :downloadDerivativePath => downloadDerivativePath, :format => file_type} %>

spec/features/dams_collections_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@
182182
expect(page).to have_selector("#collections-image img")
183183
expect(find("#collections-image img")['alt']).to eq('Heavy Metals in the Ocean Insect, Halobates')
184184
end
185+
186+
scenario 'PAGE SHOULD HAVE COLLECTION IMAGE TITLE ATTRIBUTE IN DESKTOP VIEW' do
187+
visit dams_collection_path("#{@provCollection.pid}")
188+
expect(find("#collections-image img")['title']).to eq('Heavy Metals in the Ocean Insect, Halobates')
189+
end
185190
end
186191

187192
#---

spec/features/dams_object_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,7 @@
16451645

16461646
describe "User wants to view an Image object" do
16471647
before(:all) do
1648+
@truncate_title = 'Object Files Test Object Files Test Object Files Test Object Files Test Object Files Test Object Files Test Object Files T...'
16481649
@long_title = 'Object Files Test Object Files Test Object Files Test Object Files Test Object Files Test Object Files Test Object Files Test Object Files Test'
16491650
@col = DamsAssembledCollection.create( titleValue: 'Test Collection', visibility: 'public' )
16501651
@obj = DamsObject.create( titleValue: @long_title, copyright_attributes: [ {status: 'Public domain'} ],
@@ -1671,10 +1672,11 @@
16711672
expect(page.body).to match(/embed\/#{@obj.id}\/0/)
16721673
end
16731674
end
1674-
scenario 'have image alt text' do
1675+
scenario 'have image alt text and title' do
16751676
sign_in_developer
16761677
visit dams_object_path @obj.pid
1677-
expect(find("div.simple-object a img")['alt']).to eq('Object Files Test Object Files Test Object Files Test Object Files Test Object Files Test Object Files Test Object Files T...')
1678+
expect(find("div.simple-object a img")['alt']).to eq(@truncate_title)
1679+
expect(find("div.simple-object a img")['title']).to eq(@truncate_title)
16781680
end
16791681
end
16801682

0 commit comments

Comments
 (0)