Homepage Feature

I don’t think so, because the source images are still in use and these are optimized versions. No real harm other than eating up some storage.

You could clean those up from the rails console, this covers the sizes that were included by default for the setting, and won’t remove images that were generated from a modifier elsewhere.

# 1. See what actually exists vs. what's still legitimately registered
still_needed = Topic.thumbnail_sizes +
  ThemeModifierHelper.new(theme_ids: Theme.pluck(:id)).topic_thumbnail_sizes

TopicThumbnail.group(:max_width, :max_height).count

# 2. Remove the unwanted sizes (files + records)
[[300, 300], [600, 600], [900, 900]].each do |w, h|
  next if still_needed.include?([w, h]) # don't touch sizes something else still uses

  TopicThumbnail
    .where(max_width: w, max_height: h)
    .find_each { |tt| tt.optimized_image&.destroy! }

  # attempt-records with no optimized image don't cascade
  TopicThumbnail.where(max_width: w, max_height: h).delete_all
end

oh yes, good idea — I can check to see what thumbnails exist already and if there are any, use the best size. If only the originals are available, that will always work as fallback.

Doing this here:

2 Likes