Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Convert simple PHP script in Grav Twig

Started by Ramez 7 years ago · 0 replies · 288 views
7 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 Duc , 8 hours ago
1 34 8 hours ago
Support · by Thomas, 1 week ago
3 105 17 hours ago
Support · by Anna, 4 days ago
2 101 2 days ago
Support · by Justin Young, 2 days ago
1 67 2 days ago
Support · by Duc , 1 week ago
2 106 6 days ago