Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Convert simple PHP script in Grav Twig

Started by Ramez 8 years ago · 0 replies · 486 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 alex, 2 months ago
7 620 15 hours ago
Support · by Supple, 2 days ago
0 48 2 days ago
Support · by TomW, 2 days ago
2 58 2 days ago
Support · by TomW, 6 days ago
3 153 4 days ago
Support · by TomW, 6 days ago
2 115 4 days ago