Skip to content

Instantly share code, notes, and snippets.

@markhowellsmead
Created October 29, 2019 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markhowellsmead/588ed9f838a89e75526e45c420055fc8 to your computer and use it in GitHub Desktop.
Save markhowellsmead/588ed9f838a89e75526e45c420055fc8 to your computer and use it in GitHub Desktop.
Hello Roots ServerSideRender: use LazyImage for frontend and static generation in backend
<?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