FIX: Ensure no image downloads during topic thumbnail serialization

If image uploads are missing a width/height, we re-download them to update the width/height in the database. However, this takes significant resources so we don't want to run this logic during topic serialization.
This commit is contained in:
David Taylor 2020-05-18 12:04:29 +01:00
parent 918bd75909
commit f968155288
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
1 changed files with 2 additions and 2 deletions

View File

@ -42,7 +42,7 @@ class Topic < ActiveRecord::Base
def filtered_topic_thumbnails(extra_sizes: [])
return nil unless original = image_upload
return nil unless original.width && original.height
return nil unless original.read_attribute(:width) && original.read_attribute(:height)
thumbnail_sizes = Topic.thumbnail_sizes + extra_sizes
topic_thumbnails.filter { |record| thumbnail_sizes.include?([record.max_width, record.max_height]) }
@ -50,7 +50,7 @@ class Topic < ActiveRecord::Base
def thumbnail_info(enqueue_if_missing: false, extra_sizes: [])
return nil unless original = image_upload
return nil unless original.width && original.height
return nil unless original.read_attribute(:width) && original.read_attribute(:height)
infos = []
infos << { # Always add original