Implement image resizing to save space

Created on 25 July 2023, over 1 year ago

Problem/Motivation

Downloading original images can lead to big disk usage. Pexels does provide options, to download smaller sizes, but unfortunately they tend to be to small.

Steps to reproduce

Proposed resolution

Add max width/height config when 'original' is choosen.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇸🇮Slovenia primsi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @primsi
  • Status changed to Needs review over 1 year ago
  • 🇸🇮Slovenia primsi

    Initial patch.

  • Status changed to Needs work over 1 year ago
  • 🇨🇭Switzerland berdir Switzerland
    +++ b/src/Plugin/EntityBrowser/Widget/PexelsWidget.php
    @@ -531,6 +591,13 @@ class PexelsWidget extends WidgetBase {
    +
    +          if (isset($this->configuration['resize_width']) || isset($this->configuration['resize_height'])) {
    +            /** @var \Drupal\Core\Image\Image $image */
    +            $image = $this->imageFactory->get($file_uri);
    +            $image->scale($this->configuration['resize_width'] ?? NULL, $this->configuration['resize_height'] ?? NULL);
    +            $image->save();
    +          }
    

    can't you check the download size here? Is it even necessary you first check the image width and height and only do this if either is bigger than the configured size?

  • 🇸🇮Slovenia primsi

    Thanks. Implementing that.

  • Status changed to Needs review over 1 year ago
  • 🇸🇮Slovenia primsi

    Doh. Patch is actually interdiff. Fixing

  • Status changed to Closed: won't fix 20 days ago
  • 🇸🇮Slovenia primsi

    Better approach in Provide a way to download custom size Active . Closing this one.

Production build 0.71.5 2024