image fix
This commit is contained in:
parent
f3939b8e28
commit
38f462cdbd
|
|
@ -1,5 +1,7 @@
|
|||
class EventNewsModsController < ApplicationController
|
||||
include EventNewsHelper
|
||||
DefaultImgSrc = "/assets/event_news-default.jpg\" onerror=\"this.src="/assets/event_news-default-2.jpg";this.onerror='';"
|
||||
|
||||
def initialize
|
||||
super
|
||||
@app_title = 'event_news_mod'
|
||||
|
|
@ -7,6 +9,41 @@ class EventNewsModsController < ApplicationController
|
|||
end
|
||||
def index
|
||||
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
|
||||
event_news = sorted.collect do |a|
|
||||
if a["source-site"].blank?
|
||||
|
|
@ -28,6 +65,14 @@ class EventNewsModsController < ApplicationController
|
|||
title = 'no content' if title.blank?
|
||||
event_time = a.event_time_formated_for_frontend
|
||||
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,
|
||||
"event_news_links" => links,
|
||||
|
|
@ -55,7 +100,7 @@ class EventNewsModsController < ApplicationController
|
|||
"is_top" => (a.is_top? ? 1 : 0),
|
||||
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
|
||||
"target" => target,
|
||||
"img_src" => a.image.thumb.url || "/assets/event_news-default.jpg",
|
||||
"img_src" => image_url || DefaultImgSrc,
|
||||
"img_description" => desc,
|
||||
"more" => t("event_news.more"),
|
||||
"view_count" => a.view_count
|
||||
|
|
@ -178,7 +223,7 @@ class EventNewsModsController < ApplicationController
|
|||
Category.where(:id.in => cats).pluck(:id, :title).each{|id, title_translations|
|
||||
cats_translations[id.to_s] = title_translations[I18n.locale]
|
||||
}
|
||||
cats_relations = cats_translations.map{|cat_id,t|
|
||||
cats_relations = cats_translations.map{|cat_id,t|
|
||||
if cat_id == "all"
|
||||
t = "all"
|
||||
end
|
||||
|
|
@ -206,7 +251,7 @@ class EventNewsModsController < ApplicationController
|
|||
end
|
||||
max_all_count = [OrbitHelper.widget_data_count,event_news.count].min
|
||||
if @tab_option != 0
|
||||
OrbitHelper.set_widget_title(OrbitHelper.widget_title +
|
||||
OrbitHelper.set_widget_title(OrbitHelper.widget_title +
|
||||
"<div style=\"clear: both;\"></div>" +
|
||||
"<ul class=\"nav_tabs_filter\">" +
|
||||
(use_tag ? tags.map.with_index{|tag,i|
|
||||
|
|
@ -216,7 +261,7 @@ class EventNewsModsController < ApplicationController
|
|||
if tag != "all"
|
||||
begin
|
||||
read_more_text = I18n.t("event_news.more_") + tags_translations[tag]
|
||||
rescue
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
@ -228,7 +273,7 @@ class EventNewsModsController < ApplicationController
|
|||
if cat != "all"
|
||||
begin
|
||||
read_more_text = I18n.t("event_news.more_") + cats_translations[cat]
|
||||
rescue
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
@ -267,19 +312,19 @@ class EventNewsModsController < ApplicationController
|
|||
}
|
||||
}
|
||||
var wpexLocalize = {
|
||||
"lightboxType": "iLightbox",
|
||||
"iLightbox": { "auto": false, "skin": "minimal", "path": "horizontal",
|
||||
"lightboxType": "iLightbox",
|
||||
"iLightbox": { "auto": false, "skin": "minimal", "path": "horizontal",
|
||||
"infinite": false, "maxScale": 1, "minScale": 0, "width": 1400, "height": "",
|
||||
"slideshow": { "pauseTime": 3000, "startPaused": true },
|
||||
"effects": { "reposition": true, "repositionSpeed": 200, "switchSpeed": 300,
|
||||
"loadedFadeSpeed": 50, "fadeSpeed": 500
|
||||
},
|
||||
"show": { "title": true, "speed": 200 },
|
||||
"hide": { "speed": 200 },
|
||||
"slideshow": { "pauseTime": 3000, "startPaused": true },
|
||||
"effects": { "reposition": true, "repositionSpeed": 200, "switchSpeed": 300,
|
||||
"loadedFadeSpeed": 50, "fadeSpeed": 500
|
||||
},
|
||||
"show": { "title": true, "speed": 200 },
|
||||
"hide": { "speed": 200 },
|
||||
"overlay": { "blur": true, "opacity": "0.9" },
|
||||
"slideShow": "Slideshow", "next": "Next", "previous": "Previous" ,
|
||||
"thumbnails": { "maxWidth": 120, "maxHeight": 80 }
|
||||
}
|
||||
"slideShow": "Slideshow", "next": "Next", "previous": "Previous" ,
|
||||
"thumbnails": { "maxWidth": 120, "maxHeight": 80 }
|
||||
}
|
||||
};
|
||||
$(document).ready(function(){
|
||||
var first_filter_tab = $("[data-subpart-id=\"'+subpart.id.to_s+'\"] .filter_tab").eq(0);
|
||||
|
|
@ -309,7 +354,7 @@ class EventNewsModsController < ApplicationController
|
|||
if cats.count == 1 && cats[0] != "all"
|
||||
begin
|
||||
read_more_text = I18n.t("event_news.more_") + ((all_tags.count == 1 && all_tags[0] != 'all') ? tags_translations[tags[0]] : cats_translations[cats[0]])
|
||||
rescue
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
@ -620,7 +665,7 @@ class EventNewsModsController < ApplicationController
|
|||
img_src = nil
|
||||
img_description = nil
|
||||
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?)
|
||||
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"
|
||||
|
|
@ -711,7 +756,7 @@ class EventNewsModsController < ApplicationController
|
|||
img_description = nil
|
||||
img_description = event_news["image_description_translations"][I18n.locale] if event_news['display_img']
|
||||
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']
|
||||
request = OrbitHelper.request
|
||||
if event_news["subtitle_translations"].present?
|
||||
|
|
@ -862,7 +907,7 @@ class EventNewsModsController < ApplicationController
|
|||
"is_top" => (a.is_top? ? 1 : 0),
|
||||
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
|
||||
"target" => target,
|
||||
"img_src" => a.image.thumb.url || "/assets/event_news-default.jpg",
|
||||
"img_src" => a.image.thumb.url || DefaultImgSrc,
|
||||
"img_description" => desc,
|
||||
"more" => t("event_news.more"),
|
||||
"view_count" => a.view_count
|
||||
|
|
|
|||
Loading…
Reference in New Issue