Editor plugin –> possible to resize() images?


Is it possible to have images which have been uploaded through the editor field, resized with resize()? The point is, that users might unknowingly upload images which have to be resized, because they might be too big for proper use.

In the images.php file which outputs the according block within the plugin’s folder, I tried changing this line
<img src="<?= $src ?>" alt="<?= $attrs->alt() ?>">

to this line
<img src="<?= $src->resize(500) ?>" alt="<?= $attrs->alt() ?>">

or this line
<img src="<?= $src->toFile()->resize(500) ?>" alt="<?= $attrs->alt() ?>">

with no success.


Thats odd. And what is even stranger is that if you delete the code in snippet, the image still renders in the page… what??? Must be some kind of caching or something going on.

Edit: actually it was my own stupidity… i was looking at the wrong site :frowning:

1 Like

Ah… ok… i see whats going on here. the image is a file version object. its in the media folder. I think the plugin will need a tweak. It’s not reading the file from the content folder, rather the media folder which means you can’t manipulate it further.

1 Like

You can get the file object like this: New editor: Referencing image metadata

Then you can resize it.

1 Like