Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Convert simple PHP script in Grav Twig

Started by Ramez 7 years ago · 0 replies · 411 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 complanar, 6 days ago
6 150 1 day ago
Support · by Rick Beebe, 6 days ago
2 106 3 days ago
Support · by blu3prince, 3 days ago
0 56 3 days ago
Support · by alex, 4 days ago
2 97 4 days ago
Support · by Marcel, 2 weeks ago
1 148 4 days ago