Project

General

Profile

Actions

Patch #37597

closed

Don't create two thumbnails of different resolutions for a single image

Added by Go MAEDA over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Attachments
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Currently, Redmine creates two thumbnail images for each image. This is because the img tag for displaying thumbnails requires two resolution images (see below). For example, if Setting.thumbnails_size is set to 100, a 100px thumbnail and a higher resolution version of a 200px thumbnail will be created.

<img srcset="/attachments/thumbnail/24/200 2x" style="max-width: 100px; max-height: 100px;" loading="lazy" src="/attachments/thumbnail/24" />

However, a low-resolution 100px thumbnail is unnecessary for the following reasons:

  • Nowadays, almost all web browsers support srcset attribute. The low-resolution thumbnail specified by src attribute is unnecessary for those browsers to render a page
  • Even if a user's browser does not support srcset attribute, low-resolution thumbnails are still unnecessary. Since max-width and max-hight are specified, thumbnails are displayed at the expected size even with high-resolution images

The attached patch changes ApplicationHelper#thumbnail_tag to only use a high-resolution thumbnail only.

<img srcset="/attachments/thumbnail/24/200 2x" style="max-width: 100px; max-height: 100px;" loading="lazy" src="/attachments/thumbnail/24/200" />

This reduces the number of thumbnails created when a user accesses an issue or wiki page by half. This means that halves the number of calls of an expensive Redmine::Thumbnail.generate method.


Files

Actions #1

Updated by Go MAEDA over 1 year ago

Sorry I must have been mistaken. Browsers that support srcset never GET the image specified by src attribute. But the patch is still useful because it ensures that two different sizes of thumbnails are never created.

Actions #2

Updated by Go MAEDA over 1 year ago

  • Subject changed from Halves the load of thumbnails creation to Don't create two thumbnails of different resolutions for a single image
Actions #3

Updated by Go MAEDA over 1 year ago

  • Target version set to 5.1.0

Setting the target version to 5.1.0.

Actions #4

Updated by Go MAEDA over 1 year ago

  • Category changed from Performance to Attachments
Actions #5

Updated by Go MAEDA over 1 year ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch.

Actions

Also available in: Atom PDF