Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Convert simple PHP script in Grav Twig

Started by Ramez 8 years ago · 0 replies · 435 views
8 years ago

I'm trying to transfer my current website to Grav.
I'm using i0.wp.com to resize images, and I'd like continuing using it, instead of the builtin Grav method.

However, I'm having a hard time implementing it into Grav.

I've tried several things including preg_replace and also the plugin way but I'm not able to do it.

Do you have any suggestions, how I can convert my simple PHP in Twig and make it work?

PHP
// Image
function getImage($img, $alt) {
    echo '<img class="lazyload" src="https://i0.wp.com/example.com/app/img/thumbnail.png" data-src="https://i1.wp.com/example.com/app/img/'.$img.'" data-srcset="https://i1.wp.com/example.com/app/img/'.$img.'?w=550 500w, https://i0.wp.com/example.com/app/img/'.$img.'?w=750 700w, https://i1.wp.com/example.com/app/img/'.$img.'?w=900w 1024w" alt="'.$alt.'">';
}

Suggested topics

Topic Participants Replies Views Activity
Support · by webmasterodp, 7 days ago
4 153 6 days ago
Support · by nwhitfield, 1 week ago
2 134 1 week ago
Support · by stell, 3 weeks ago
5 369 2 weeks ago
Support · by gravinator, 1 month ago
5 559 2 weeks ago
Support · by Gravver, 3 weeks ago
6 347 3 weeks ago