From 8b6566da6b1bbafce32e7776d414917f0026c5ea Mon Sep 17 00:00:00 2001 From: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> Date: Wed, 22 Apr 2020 13:04:32 -0600 Subject: [PATCH] Allow Height and Width to be Specified in Options (#7417) * Allow height and width to be specified in options in CloudCoverUrl * Allow height and width to be specified in options in social_image.rb * Remove options from cloud_cover_url.rb in favor of social_image.rb * Add double splat operator for height and width options in social_image.rb * Add double splat operator to options in application_helper.rb * Add options to call in article_serializer.rb * Remove options from the CloudCOverUrl call in application_helper.rb * Remove options from article_serializer.rb * Add height and width variables to cl_image_path * Remove hardcoded height and width from social_image.rb * Adjust width to be 500 rather than 420 in social_image.rb --- app/view_objects/articles/social_image.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/view_objects/articles/social_image.rb b/app/view_objects/articles/social_image.rb index 8b1f216e3..da3889da3 100644 --- a/app/view_objects/articles/social_image.rb +++ b/app/view_objects/articles/social_image.rb @@ -3,8 +3,10 @@ module Articles include Rails.application.routes.url_helpers include CloudinaryHelper - def initialize(article) + def initialize(article, **options) @article = article + @height = options[:height] || 500 + @width = options[:width] || 1000 end SOCIAL_PREVIEW_MIGRATION_DATETIME = Time.zone.parse("2019-04-22T00:00:00Z") @@ -14,8 +16,8 @@ module Articles if image.present? return cl_image_path(image, type: "fetch", - width: "1000", - height: "500", + width: height, + height: width, crop: "imagga_scale", quality: "auto", flags: "progressive", @@ -29,7 +31,7 @@ module Articles private - attr_reader :article + attr_reader :article, :height, :width def legacy_article_social_image cache_key = "article-social-img-#{article}-#{article.updated_at.rfc3339}-#{article.comments_count}"