Created
October 29, 2019 09:36
-
-
Save markhowellsmead/588ed9f838a89e75526e45c420055fc8 to your computer and use it in GitHub Desktop.
Hello Roots ServerSideRender: use LazyImage for frontend and static generation in backend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (array_key_exists('context', $_GET) && $_GET['context'] === 'edit') { | |
$featured_image = wp_get_attachment_image(get_post_thumbnail_id($post->ID), $size, false, ['class' => 'b-articles-latest__entryimage']); | |
if (!empty($featured_image)) { | |
$featured_image = '<figure class="b-articles-latest__entryfigure">'.$featured_image.'</figure>'; | |
} | |
} else { | |
$featured_image = sht_theme()->Package->Lazysizes->getLazyImage(get_post_thumbnail_id($post->ID), $size, 'b-articles-latest__entryfigure', 'b-articles-latest__entryimage'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment