added image alternate text

This commit is contained in:
Harry Bomrah 2015-06-02 17:48:18 +08:00
parent 54012254ce
commit 69c0959b31
1 changed files with 10 additions and 3 deletions

View File

@ -17,6 +17,8 @@ class AnnouncementsController < ApplicationController
files = a.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } } rescue [] files = a.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } } rescue []
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
author = User.find(a.create_user_id).member_profile.name rescue "" author = User.find(a.create_user_id).member_profile.name rescue ""
desc = a.image_description
desc = (desc.nil? || desc == "" ? "announcement image" : desc)
{ {
"bulletin_links" => links, "bulletin_links" => links,
"bulletin_files" => files, "bulletin_files" => files,
@ -28,7 +30,7 @@ class AnnouncementsController < ApplicationController
"author" => author, "author" => author,
"link_to_show" => OrbitHelper.url_to_show(a.to_param), "link_to_show" => OrbitHelper.url_to_show(a.to_param),
"img_src" => a.image.thumb.url || "/assets/announcement-default.jpg", "img_src" => a.image.thumb.url || "/assets/announcement-default.jpg",
"img_description" => a.image_description, "img_description" => desc,
"more" => t(:more_plus), "more" => t(:more_plus),
"view_count" => a.view_count "view_count" => a.view_count
} }
@ -73,6 +75,8 @@ class AnnouncementsController < ApplicationController
files = a.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } } rescue [] files = a.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } } rescue []
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
author = User.find(a.create_user_id).member_profile.name rescue "" author = User.find(a.create_user_id).member_profile.name rescue ""
desc = a.image_description
desc = (desc.nil? || desc == "" ? "announcement image" : desc)
{ {
"bulletin_links" => links, "bulletin_links" => links,
"bulletin_files" => files, "bulletin_files" => files,
@ -84,7 +88,7 @@ class AnnouncementsController < ApplicationController
"author" => author, "author" => author,
"link_to_show" => OrbitHelper.widget_item_url(a.to_param), "link_to_show" => OrbitHelper.widget_item_url(a.to_param),
"img_src" => a.image.thumb.url || "/assets/announcement-default.jpg", "img_src" => a.image.thumb.url || "/assets/announcement-default.jpg",
"img_description" => a.image_description "img_description" => desc
} }
end end
mp = (anns[0]["img_src"] rescue "") mp = (anns[0]["img_src"] rescue "")
@ -129,6 +133,8 @@ class AnnouncementsController < ApplicationController
links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
update_user = announcement.update_user.member_profile.name rescue "" update_user = announcement.update_user.member_profile.name rescue ""
desc = announcement.image_description
desc = (desc.nil? || desc == "" ? "announcement image" : desc)
{ {
"tags" => tags, "tags" => tags,
"bulletin_files" => files, "bulletin_files" => files,
@ -138,7 +144,8 @@ class AnnouncementsController < ApplicationController
"update_user" => update_user, "update_user" => update_user,
"updated_at" => announcement.postdate.strftime('%Y-%m-%d %H:%M'), "updated_at" => announcement.postdate.strftime('%Y-%m-%d %H:%M'),
"body" =>announcement.text, "body" =>announcement.text,
"image" => announcement.image.url "image" => announcement.image.url,
"alt_title" => desc
}, },
"impressionist" => (announcement.is_preview ? nil : announcement), "impressionist" => (announcement.is_preview ? nil : announcement),
"url_to_edit"=>url_to_edit "url_to_edit"=>url_to_edit