[Resolved] Prevent Featured Images from Loading on Pages

Home Forums Support Prevent Featured Images from Loading on Pages

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #471877
    Nathan

    Hi folks… what I’m after is the ability to prevent featured images from loading at all on pages. I want my clients to be able to add a featured image to a page so that it shows up correctly on the OpenGraph when it’s shared on social, but I don’t want the image to display on the front end.

    Yes, I know I can hide with CSS, but the image is still actually loading, which affects page speed. So I don’t want to just display:none the featured image.

    I’ve found this file generatepress > inc > structure > featured-images.php and I’ve added a conditional to line 59 to prevent the home page image from loading:

    if ( ! has_post_thumbnail() || ! is_home() ) {

    The above works and prevents the featured image from loading on the Home Page. Here are my issues…

    (1) It doesn’t work with is_page() for some reason to prevent loading on all pages, Only works for is_home().

    (2) Also, I know hacking the theme isn’t the solution, but when I tried to move the file to my child theme (replicating the folder structure as I have with other themes and placing the php file inside), Generatepress is not picking up my revisions and is reading the core theme file instead.

    I have the following folder structure in place: generatepress-child > inc > structure > featured-images.php.

    If you could explain how to solve the above 2 issues or if you have a better way of accomplishing this (which is quite possibly something simple I’ve completely overlooked), I’d appreciate it!

    GeneratePress 2.0.1
    GP Premium 1.5.6
    #471922
    Leo
    Staff
    Customer Support
    #472300
    Nathan

    And there’s the something simple I overlooked. 🙂

    Actually, I didn’t have the blog option enabled in Premium, so that explains it.

    Thanks for the quick response as always. You guys are great!

    #472420
    Leo
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.