[Support request] Disable elements featured image

Home Forums Support [Support request] Disable elements featured image

Home Forums Support Disable elements featured image

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2069075
    Javier

    I have noticed that when I deactivate with the generate press premium plugin the featured image on a page, it is hidden with display: none

    I don’t think this is the best way to disable an element. I think it should be disabled by not calling the function that paints the HTML of the featured image instead of always calling it and then putting a display: none.

    Do you think this could be fixed for a future update?

    Older queries have already reported this problem and have not changed it for the image. I don’t think the best thing to do is to load the image and then hide it with a display:none because that means that the page takes longer to load and the performance is lost.

    #2069096
    Javier

    I have seemed to discover that when in the customizer you configure to show featured image on pages above the content is when the featured image is loaded on the page and then hidden with a display none.

    If you set display image above the title or below the title, when I disable the featured image element, it no longer loads in the HTML.

    #2069102
    Javier

    what I said before is wrong, it still loads the featured image and hides it with display: none

    You should fix this behavior

    Thanks

    #2069104
    Ying
    Staff
    Customer Support

    Hi Javier,

    Are you talking about the disable elements in the page editor?

    Can you try using a layout element instead?

    #2069121
    Javier

    If I use disable elements creating a design from the element editor it works fine but, I am not interested in using a design element. I am interested in using the disable elements options for the reason that then my client will have the option to disable or enable from each page that will be easier than having to teach him to do it from the element editor that is more sensitive to error.

    #2069220
    Ying
    Staff
    Customer Support

    I just talked to Tom, he would look into it 🙂

    For now, I would recommend using layout element.

    #2069640
    Javier

    Will I get an answer soon?

    #2069736
    David
    Staff
    Customer Support

    Hi there,

    it will require an update to GP Premium, which we will look to include in the next update. In the meantime you can try the following:

    1. Create a Layout Element to Disable the Featured Image.
    1.1 Do not set any Display Rules for the Element.
    1.2 Whilst editing the layout Element inpsect the URL in the browser field and get the elements ID.

    2. Add this PHP Snippet:

    add_filter( 'generate_element_display', function( $display, $element_id ) {
        if ( 123 === $element_id ) { // Only target specific Element
            if ( has_post_thumbnail() && get_post_meta( get_the_ID(), '_generate-disable-post-image', true ) === 'true' ) {
                $display = true;
            }
        }
        return $display;
    }, 10, 2 );

    Change the 123 to match your Elements ID.

    This should apply the Layout Element to disable the featured image IF the post has a featured image and the disable featured image option is selected.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.