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
This commit is contained in:
Julianna Tetreault 2020-04-22 13:04:32 -06:00 committed by GitHub
parent f677e7f4f0
commit 8b6566da6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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}"