image fix
This commit is contained in:
parent
f3939b8e28
commit
38f462cdbd
|
|
@ -1,5 +1,7 @@
|
||||||
class EventNewsModsController < ApplicationController
|
class EventNewsModsController < ApplicationController
|
||||||
include EventNewsHelper
|
include EventNewsHelper
|
||||||
|
DefaultImgSrc = "/assets/event_news-default.jpg\" onerror=\"this.src="/assets/event_news-default-2.jpg";this.onerror='';"
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super
|
super
|
||||||
@app_title = 'event_news_mod'
|
@app_title = 'event_news_mod'
|
||||||
|
|
@ -7,6 +9,41 @@ class EventNewsModsController < ApplicationController
|
||||||
end
|
end
|
||||||
def index
|
def index
|
||||||
EventNews.remove_expired_status
|
EventNews.remove_expired_status
|
||||||
|
params = @params = OrbitHelper.params
|
||||||
|
page = @page || Page.where(url: params['url']).first
|
||||||
|
@enable_search_flag = false
|
||||||
|
@image_version = 'thumb'
|
||||||
|
if page.respond_to?(:select_option_items)
|
||||||
|
module_app = ModuleApp.where(key: @app_title).first
|
||||||
|
@show_option_items = nil
|
||||||
|
if module_app && page.respond_to?(:select_option_items)
|
||||||
|
@show_option_items = module_app.show_option_items
|
||||||
|
end
|
||||||
|
I18n.with_locale(:en) do
|
||||||
|
page.select_option_items.each do |select_option_item|
|
||||||
|
if !(@show_option_items.nil?)
|
||||||
|
case select_option_item.field_name
|
||||||
|
when @show_option_items.keys[1].to_s
|
||||||
|
value = YAML.load(select_option_item.value)
|
||||||
|
if value[:en] == t('event_news.yes')
|
||||||
|
@enable_search_flag = true
|
||||||
|
end
|
||||||
|
when @show_option_items.keys[4].to_s
|
||||||
|
value = YAML.load(select_option_item.value)
|
||||||
|
tmp = value[:en]
|
||||||
|
if tmp == t('event_news.small_size')
|
||||||
|
@image_version = 'thumb'
|
||||||
|
elsif tmp == t('event_news.medium_size')
|
||||||
|
@image_version = 'mobile'
|
||||||
|
elsif tmp == t('event_news.orignal_size')
|
||||||
|
@image_version = 'orignal'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
sorted,total_pages = get_sorted_event_news
|
sorted,total_pages = get_sorted_event_news
|
||||||
event_news = sorted.collect do |a|
|
event_news = sorted.collect do |a|
|
||||||
if a["source-site"].blank?
|
if a["source-site"].blank?
|
||||||
|
|
@ -28,6 +65,14 @@ class EventNewsModsController < ApplicationController
|
||||||
title = 'no content' if title.blank?
|
title = 'no content' if title.blank?
|
||||||
event_time = a.event_time_formated_for_frontend
|
event_time = a.event_time_formated_for_frontend
|
||||||
event_time_formated = a.event_time_formated
|
event_time_formated = a.event_time_formated
|
||||||
|
if @image_version == 'thumb'
|
||||||
|
image_url = a.image.thumb.url
|
||||||
|
elsif @image_version == 'mobile'
|
||||||
|
image_url = a.image.mobile.url
|
||||||
|
else
|
||||||
|
image_url = a.image.url
|
||||||
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
"department" => author,
|
"department" => author,
|
||||||
"event_news_links" => links,
|
"event_news_links" => links,
|
||||||
|
|
@ -55,7 +100,7 @@ class EventNewsModsController < ApplicationController
|
||||||
"is_top" => (a.is_top? ? 1 : 0),
|
"is_top" => (a.is_top? ? 1 : 0),
|
||||||
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
|
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
|
||||||
"target" => target,
|
"target" => target,
|
||||||
"img_src" => a.image.thumb.url || "/assets/event_news-default.jpg",
|
"img_src" => image_url || DefaultImgSrc,
|
||||||
"img_description" => desc,
|
"img_description" => desc,
|
||||||
"more" => t("event_news.more"),
|
"more" => t("event_news.more"),
|
||||||
"view_count" => a.view_count
|
"view_count" => a.view_count
|
||||||
|
|
@ -620,7 +665,7 @@ class EventNewsModsController < ApplicationController
|
||||||
img_src = nil
|
img_src = nil
|
||||||
img_description = nil
|
img_description = nil
|
||||||
subtitle_ann = event_news.subtitle if event_news.display_subtitle?
|
subtitle_ann = event_news.subtitle if event_news.display_subtitle?
|
||||||
img_src = (event_news.image.thumb.url || "/assets/event_news-default.jpg") if event_news.display_img?
|
img_src = (event_news.image.thumb.url || DefaultImgSrc) if event_news.display_img?
|
||||||
img_description = event_news.image_description if (event_news.image_description.present?) && (event_news.display_img?)
|
img_description = event_news.image_description if (event_news.image_description.present?) && (event_news.display_img?)
|
||||||
event_carousel_images = event_news.event_carousel_images.map{|image| {"src"=>image.file.url,"description"=>image.description.to_s,"description_text"=>image.description_text }}
|
event_carousel_images = event_news.event_carousel_images.map{|image| {"src"=>image.file.url,"description"=>image.description.to_s,"description_text"=>image.description_text }}
|
||||||
resume_btn_title = (I18n.locale.to_s =="zh_tw") ? "繼續播放" : "resume"
|
resume_btn_title = (I18n.locale.to_s =="zh_tw") ? "繼續播放" : "resume"
|
||||||
|
|
@ -711,7 +756,7 @@ class EventNewsModsController < ApplicationController
|
||||||
img_description = nil
|
img_description = nil
|
||||||
img_description = event_news["image_description_translations"][I18n.locale] if event_news['display_img']
|
img_description = event_news["image_description_translations"][I18n.locale] if event_news['display_img']
|
||||||
img_src = nil
|
img_src = nil
|
||||||
img_src = (event_news['image']['original'] || "/assets/event_news-default.jpg") if event_news['display_img']
|
img_src = (event_news['image']['original'] || DefaultImgSrc) if event_news['display_img']
|
||||||
subtitle_ann = event_news['subtitle_ann']
|
subtitle_ann = event_news['subtitle_ann']
|
||||||
request = OrbitHelper.request
|
request = OrbitHelper.request
|
||||||
if event_news["subtitle_translations"].present?
|
if event_news["subtitle_translations"].present?
|
||||||
|
|
@ -862,7 +907,7 @@ class EventNewsModsController < ApplicationController
|
||||||
"is_top" => (a.is_top? ? 1 : 0),
|
"is_top" => (a.is_top? ? 1 : 0),
|
||||||
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
|
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
|
||||||
"target" => target,
|
"target" => target,
|
||||||
"img_src" => a.image.thumb.url || "/assets/event_news-default.jpg",
|
"img_src" => a.image.thumb.url || DefaultImgSrc,
|
||||||
"img_description" => desc,
|
"img_description" => desc,
|
||||||
"more" => t("event_news.more"),
|
"more" => t("event_news.more"),
|
||||||
"view_count" => a.view_count
|
"view_count" => a.view_count
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue