From 3d2a33a9b85c026200bf031911ffd6dedd69f7d6 Mon Sep 17 00:00:00 2001 From: Bohung Date: Mon, 17 Jan 2022 20:05:10 +0800 Subject: [PATCH] Edit images src. --- app/controllers/galleries_controller.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 71a276f..5f48330 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -65,12 +65,17 @@ class GalleriesController < ApplicationController doc = Nokogiri::HTML(a.description.to_s) alt_text = doc.text.empty? ? 'gallery image' : doc.text colors = album_color_map[a.id] || [] + thumb_src = a.cover_path || "/assets/gallery/default.jpg" { "album-name" => a.name, "album-description" => a.description, "alt_title" => alt_text, "link_to_show" => OrbitHelper.url_to_show(a.to_param), - "thumb-src" => a.cover_path || "/assets/gallery/default.jpg", + "thumb-src" => thumb_src, + "src" => thumb_src.sub('thumb_','') , + "thumb-large-src" => thumb_src.sub("thumb_","thumb_large_"), + "mobile-src" => thumb_src.sub("thumb_","mobile_"), + "theater-src" => thumb_src.sub("thumb_","theater_"), "album_color" => iterate_data(colors[1],colors[0],@album_setting.album_card_background_color,'transparent'), "album_card_text_color" => iterate_data(colors[2],@album_setting.album_card_text_color) } @@ -161,11 +166,11 @@ class GalleriesController < ApplicationController "album-description" => a.description, "alt_title" => alt_text, "link_to_show" => OrbitHelper.widget_more_url + "/" + a.to_param + "#" + (cover_image.id.to_s rescue ""), - "src" => thumb_src.gsub("thumb_",""), + "src" => thumb_src.sub("thumb_",""), "thumb-src" => thumb_src, - "thumb-large-src" => thumb_src.gsub("thumb_","thumb_large_"), - "mobile-src" => thumb_src.gsub("thumb_","mobile_"), - "theater-src" => thumb_src.gsub("thumb_","theater_"), + "thumb-large-src" => thumb_src.sub("thumb_","thumb_large_"), + "mobile-src" => thumb_src.sub("thumb_","mobile_"), + "theater-src" => thumb_src.sub("thumb_","theater_"), "image_description" => image_description, "image_short_description" => image_short_description, "album_color" => iterate_data(colors[1],colors[0],@album_setting.album_card_background_color,'transparent'),