From f968155288b7450056b50680cc2d2dd8f7d8bee9 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 18 May 2020 12:04:29 +0100 Subject: [PATCH] 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. --- app/models/topic.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/topic.rb b/app/models/topic.rb index 22307a8dad1..d331a308060 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -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