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

Also available in: Atom PDF