removing image div from the blocks if there are no images
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 27 Jul 2017 20:38:16 +0000 (16:38 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 27 Jul 2017 20:38:16 +0000 (16:38 -0400)
checking to make sure the blocks have an image url before trying to put the url for the block
as a bg url

parts/glm-blocks.php

index 04fe829..6b4e549 100644 (file)
@@ -39,7 +39,11 @@ default:
                   <?php  $image = get_the_post_thumbnail_url($block->ID, 'full'); ?>
                     <a href="<?php echo $block->url;?>"<?php if($block->externalUrl){echo ' target="_blank"';}?>>
                         <?php endif;?>
-                        <div class="interior-block-image" style="background-image: url(<?php echo $image; ?>)"></div>
+                        <?php if($image){ ?>
+                            <div class="interior-block-image" style="background-image: url(<?php echo $image; ?>)"></div>
+                        <?php } else { ?>
+                            <div class="block-no-image"></div>
+                        <?php } ?>
                         <?php if($block->url):?>
                     </a>
                 <?php endif;?>