Snippet for resizing Images in MODX. It replaces pThumb in 99% of my projects, but can be used in parallel 😸
✅ Generates WebP
✅ Output srcset and aspect ratio for better web vitals
✅ Can use binary libs like convert
(Imagine workaround on IONOS) and ffmpeg
(for Videothumbnails)
✅ Output as base64 for Lazyloading Placeholders
MODX-resizeImage/resizeimage.snippet.php
Lines 4 to 13 in 9f0cc0b
<img
data-srcset[[!resizeImage?
&input=`[[+url]]`
&options=`2000,1250,800` ]]
alt=""
/>
Generates this:
<img
data-srcset="
assets/image-cache/dummy1.6bee3066.2000x-70.webp 2000w,
assets/image-cache/dummy1.143b6e11.1250x-70.webp 1250w,
assets/image-cache/dummy1.b23222b6.800x-70.webp 800w
"
width="2000"
height="1193"
style="aspect-ratio: 2000/1193"
alt=""
/>
ℹ️ Allways call the Snippet uncached, to prevent missing images when old images get deleted by the Snippet themself.
<img
src[[!resizeImage?
&input=`[[+url]]`
&options=`100`
&lib=`cli`
&libPath=`[[++ffmpeg.binPath]]`
&type=`video`
&fileExtension=`png`
&mode=`base64` ]]
alt=""
/>
- Test and get Feedback
- Make it avaible as MODX Package