From c23cfbbba2c1f93977f35c0b7164feee4601385e Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Tue, 20 Oct 2020 21:24:23 +0200 Subject: [PATCH] Watermark now on east. New method for medium-sized images --- app/models/screenshot.rb | 15 ++++++++++++--- app/views/packages/details.slim | 10 +++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/models/screenshot.rb b/app/models/screenshot.rb index 837a164..cf9c266 100644 --- a/app/models/screenshot.rb +++ b/app/models/screenshot.rb @@ -162,11 +162,20 @@ class Screenshot < ApplicationRecord #Digest::MD5.base64digest(Net::HTTP.get(URI(url))) end - # Returns the URL that links to a full-size screenshot image with a watermark - def large_watermarked + # Returns the image variant that links to a full-size screenshot image with a watermark + def medium_image if self.image.attached? self.image.variant( - gravity: 'SouthEast', + resize_to_limit: [670, 600] + ).processed + end + end + + # Returns the image variant that links to a medium-size screenshot for the details page + def large_image_watermarked + if self.image.attached? + self.image.variant( + gravity: 'East', draw: 'image Over 0,0 0,0 "public/logo/watermark.png"' ).processed end diff --git a/app/views/packages/details.slim b/app/views/packages/details.slim index ba7f8d7..596b4e2 100644 --- a/app/views/packages/details.slim +++ b/app/views/packages/details.slim @@ -19,9 +19,9 @@ .margin-bottom-3 / TODO: de-duplicate - a href =url_for(screenshot.large_watermarked) rel='fancybox-thumb' title=screenshot.caption data-fancybox='gallery' data-caption=screenshot_caption(screenshot) + a href =url_for(screenshot.large_image_watermarked) rel='fancybox-thumb' title=screenshot.caption data-fancybox='gallery' data-caption=screenshot_caption(screenshot) .image-with-zoom-icon - = image_tag(url_for(screenshot.image), alt: screenshot.caption, class: 'thumbnail') + = image_tag(url_for(screenshot.medium_image), alt: screenshot.caption, class: 'thumbnail') .magnifying-glass-icon i.fa.fa-search @@ -34,12 +34,12 @@ / Display further screenshots as smaller images - else - .small-6.medium-6.cell + .small-12.medium-6.cell .margin-bottom-3 - a href =url_for(screenshot.large_watermarked) rel='fancybox-thumb' title=screenshot.caption data-fancybox='gallery' data-caption=screenshot_caption(screenshot) + a href =url_for(screenshot.large_image_watermarked) rel='fancybox-thumb' title=screenshot.caption data-fancybox='gallery' data-caption=screenshot_caption(screenshot) .image-with-zoom-icon - = image_tag(url_for(screenshot.image), alt: screenshot.caption, class: 'thumbnail') + = image_tag(url_for(screenshot.medium_image), alt: screenshot.caption, class: 'thumbnail') .magnifying-glass-icon i.fa.fa-search