diff --git a/app/models/concerns/tipline_content_image.rb b/app/models/concerns/tipline_content_image.rb index faa902dd83..a85c8af8c1 100644 --- a/app/models/concerns/tipline_content_image.rb +++ b/app/models/concerns/tipline_content_image.rb @@ -30,7 +30,12 @@ def convert_header_file_image temp_name = 'temp-' + self.id.to_s + '-' + self.language + '.html' temp = File.join(Rails.root, 'public', content_name, temp_name) output = File.open(temp, 'w+') - output.puts doc.to_s.gsub('%IMAGE_URL%', CheckS3.rewrite_url(self.header_file_url.to_s)) + + # Replace the image in the template + image_url = CheckS3.rewrite_url(self.header_file_url.to_s) + w, h = ::MiniMagick::Image.open(image_url)[:dimensions] + image_class = w > h ? 'wider' : 'taller' + output.puts doc.to_s.gsub('%IMAGE_URL%', image_url).gsub('%IMAGE_CLASS%', image_class) output.close # Upload the HTML to S3 @@ -39,7 +44,7 @@ def convert_header_file_image temp_url = CheckS3.public_url(path) # Convert the HTML to PNG - uri = URI("#{CheckConfig.get('narcissus_url')}/?url=#{CheckS3.rewrite_url(temp_url)}&selector=%23frame") + uri = URI("#{CheckConfig.get('narcissus_url')}/?selector=img&url=#{CheckS3.rewrite_url(temp_url)}") request = Net::HTTP::Get.new(uri) request['x-api-key'] = CheckConfig.get('narcissus_token') response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(request) } diff --git a/config/config.yml.example b/config/config.yml.example index 3943600acd..63a205f99e 100644 --- a/config/config.yml.example +++ b/config/config.yml.example @@ -286,6 +286,7 @@ test: otel_log_level: error otel_traces_sampler: sentry_dsn: + storage_rewrite_host: 'http://minio:9000' # Facebook social login # diff --git a/public/tipline-content-template.html b/public/tipline-content-template.html index 6a6bd4c22b..143597e2f8 100644 --- a/public/tipline-content-template.html +++ b/public/tipline-content-template.html @@ -1,7 +1,7 @@ - Tipline Newsletter Template + Tipline Content Template
-
-
-
+ Background image +
- - Background image