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

Comments

Primsi created an issue. See original summary.

primsi’s picture

Status: Active » Needs review
StatusFileSize
new4.6 KB

Initial patch.

berdir’s picture

Status: Needs review » Needs work
+++ 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?

primsi’s picture

Thanks. Implementing that.

primsi’s picture

Status: Needs work » Needs review
StatusFileSize
new4 KB

Doh. Patch is actually interdiff. Fixing

primsi’s picture

Status: Needs review » Closed (won't fix)

Better approach in #3489842: Provide a way to download custom size. Closing this one.