image alternate text for all of stuff

This commit is contained in:
Harry Bomrah 2015-05-28 17:48:35 +08:00
parent c98ceae1d6
commit 011f1c0f1e
2 changed files with 11 additions and 2 deletions

View File

@ -2,9 +2,11 @@ class GalleriesController < ApplicationController
def index def index
albums = Album.filter_by_categories.asc(:order) albums = Album.filter_by_categories.asc(:order)
galleries = albums.collect do |a| galleries = albums.collect do |a|
alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description)
{ {
"album-name" => a.name, "album-name" => a.name,
"album-description" => a.description, "album-description" => a.description,
"alt_title" => alt_text,
"link_to_show" => OrbitHelper.url_to_show(a.to_param), "link_to_show" => OrbitHelper.url_to_show(a.to_param),
"thumb-src" => a.cover_path || "/assets/gallery/default.jpg" "thumb-src" => a.cover_path || "/assets/gallery/default.jpg"
} }
@ -21,8 +23,10 @@ class GalleriesController < ApplicationController
params = OrbitHelper.params params = OrbitHelper.params
album = Album.find_by_param(params[:uid]) album = Album.find_by_param(params[:uid])
images = album.album_images.asc(:order).collect do |a| images = album.album_images.asc(:order).collect do |a|
alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description)
{ {
"image-description" => a.description, "image-description" => a.description,
"alt_title" => alt_text,
"link_to_show" => "/" + I18n.locale.to_s + params[:url] + "/-" + a.id.to_s + "?method=theater", "link_to_show" => "/" + I18n.locale.to_s + params[:url] + "/-" + a.id.to_s + "?method=theater",
"thumb-src" => a.file.thumb.url "thumb-src" => a.file.thumb.url
} }
@ -57,8 +61,11 @@ class GalleriesController < ApplicationController
end end
end end
images = images.collect do |a| images = images.collect do |a|
alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description)
{ {
"link_to_show" => OrbitHelper.widget_more_url + "/-" + a.id.to_s + "?method=theater", "link_to_show" => OrbitHelper.widget_more_url + "/-" + a.id.to_s + "?method=theater",
"alt_title" => alt_text,
"thumb-src" => a.file.thumb.url "thumb-src" => a.file.thumb.url
} }
end end
@ -74,9 +81,11 @@ class GalleriesController < ApplicationController
images = album.album_images.asc(:order) images = album.album_images.asc(:order)
output = Array.new output = Array.new
images.each do |values| images.each do |values|
alt_text = (values.description.nil? || values.description == "" ? "gallery image" : values.description)
output << { _id: values.id.to_s, output << { _id: values.id.to_s,
description: values.description, description: values.description,
title: values.title, title: values.title,
alt_title: alt_text,
file: values.file.as_json[:file], file: values.file.as_json[:file],
gallery_album_id: values.album_id, gallery_album_id: values.album_id,
tags: values.tags} tags: values.tags}

View File

@ -15,7 +15,7 @@
<div id="imgholder"> <div id="imgholder">
<div class="rslide" style="position:relative; width:100%;"> <div class="rslide" style="position:relative; width:100%;">
<div class="rslideinside"><div id="loading" style="display:none;"></div> <div class="rslideinside"><div id="loading" style="display:none;"></div>
<div class="comp" id='main_pic' data-content='<%= @image.album_id %>'><a href="" id="nextpic" class="navN" title="下一張" onclick="return false;" ><img src="<%= @image.file.theater.url %>" alt="" /></a></div> <div class="comp" id='main_pic' data-content='<%= @image.album_id %>'><a href="" id="nextpic" class="navN" title="下一張" onclick="return false;" ><img src="<%= @image.file.theater.url %>" alt="<%= @image.description.nil? || @image.description == "" ? "gallery image" : @image.description %>" /></a></div>
<div class="rslidenav"> <div class="rslidenav">
<a href="" class="navP" title="上一張" onclick="return false;">Prev</a> <a href="" class="navP" title="上一張" onclick="return false;">Prev</a>
<a href="" class="navN" title="下一張" onclick="return false;">Next</a> <a href="" class="navN" title="下一張" onclick="return false;">Next</a>
@ -24,7 +24,7 @@
<div class="slidelist"> <div class="slidelist">
<ul id='galleryimagelist' style="display:none;"> <ul id='galleryimagelist' style="display:none;">
<% @images.each_with_index do |image,i| %> <% @images.each_with_index do |image,i| %>
<li for="<%= i %>"><a href="<%= image.id %>" class="list_element" data-content="<%= image.file.theater.url %>" onclick="return false;"><img src="<%= image.file.thumb.url %>" alt="" /></a></li> <li for="<%= i %>"><a href="<%= image.id %>" class="list_element" data-content="<%= image.file.theater.url %>" onclick="return false;"><img src="<%= image.file.thumb.url %>" alt="<%= image.description.nil? || image.description == "" ? "gallery image" : image.description %>" /></a></li>
<% end %> <% end %>
</ul> </ul>
</div> </div>