I've installed and configured the Image resize filter (e.g. enabled it in the Enabled filters section admin/config/content/formats/manage/full_html).
Also I've created a content, uploaded a big image, resized it to small in the wysiwyg editor and saved it.
If I "view" the code through website code viewer I see that the IMG tag has set up width and height of the image, but "actual size" of the image comming from server is the full size of the image.

Drupal 8.2.2

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nor4a created an issue. See original summary.

gnuget’s picture

Hi!

Did you try ordering the filters? the resize filter must be the last one to be executed.

Also, for now, it only supports images uploaded through the editor (inline images).

gnuget’s picture

Status: Active » Postponed (maintainer needs more info)

I'm going to postpone this until we have more info.

Nor4a’s picture

I take a look at the code in the file FilterImageResize.php

...
private function getImages($text) {
    $dom = Html::load($text);
    $xpath = new \DOMXPath($dom);
    /** @var \DOMNode $node */
    foreach ($xpath->query('//img') as $node) {
      $file = $this->entityRepository->loadEntityByUuid('file', $node->getAttribute('data-entity-uuid'));
      // If the image hasn't an uuid then don't try to resize it.
      if (is_null($file)) {
        continue;
      }
      $image = $this->imageFactory->get($node->getAttribute('src'));
      // Checking if the image needs to be resized.
      if ($image->getWidth() == $node->getAttribute('width') && $image->getHeight() == $node->getAttribute('height')) {
        continue;
      }
...

And I see the data-entity-uuid is required for the code to work. But images inserted through the IMCE editor does not have the data-entity-uuid! Probably this is the issue...

gnuget’s picture

Title: Does not resize the image » Support images uploaded using IMCE
Status: Postponed (maintainer needs more info) » Active

Yeah, I think that is the problem.

Nor4a’s picture

Yes - I checked - it works with the default image upload button as it provides the data-entity-uuid.

RobertoGuzman’s picture

i have the same issue, any update ?

gnuget’s picture

Status: Active » Needs review
FileSize
21.8 KB

Ok, we finally have progress here!

The thing is, the first version of this port was taking advantage of the UUID attribute of the images, this allows to keep it SUPER small because all the code to get info from the images was removed and Drupal was providing it, but sadly I couldn't find a way to get that info from images without UUID and even this let us with a few missing features like the support for remote images.

So I now restored the code that handles that so we can support any image uploaded and this allows us to add support for the remote images in the D8 version.

So patch attached, let me know if it is working for you.

Regards!

gnuget’s picture

FileSize
31.21 KB

A small note, just as the D7 version, you need to configure the plugin in the filter formats page:

Image Resize Filter settings

rang501’s picture

Hi!

I tried to merge #2896172: No configuration options into this, hopefully this helps someone.

  • ram4nd committed ffe541e on 8.x-1.x authored by gnuget
    Issue #2825339 by gnuget, Nor4a: Support images uploaded using IMCE
    
mlncn’s picture

Status: Needs review » Reviewed & tested by the community

Sweet! All of Gnuget's original patch, except for the addition of the composer.json and i think the config schema file have been committed to the 8.x-1.x branch there. This issue can probably be closed then? Those extra files are worth committing separately i think.

ram4nd’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.