• Resolved renanbessa

    (@renanbessa)


    Hi support!

    I created a function to add the data-amp-auto-lightbox-disable attribute to disable the lightbox only for the featured image. This attribute is inserted normally in the html in the non-amp version. Is there a filter to work also on amp pages?

    Below the created code

    // Disable lighthox amp thumbnail post
    function disable_lightbox_amp($html) {
    
    	if ( !is_singular() ) {
    		return; // archive or 404
    	}
    
    	$disable_lightbox_amp = 'data-amp-auto-lightbox-disable';
    	$html = substr_replace( $html, $disable_lightbox_amp, -1, 0 );
    	
    	return $html;
    }
    add_filter( 'post_thumbnail_html', 'disable_lightbox_amp' );
    

    Below the html output in the non amp version

    View post on imgur.com

    • This topic was modified 3 years, 10 months ago by renanbessa.
    • This topic was modified 3 years, 10 months ago by renanbessa.
Viewing 2 replies - 1 through 2 (of 2 total)
  • If you’re looking to remove the lightbox effect you could add the data-amp-auto-lightbox-disable attribute between your themes body tag (more details here). You can still use the toggle configuration for images individually to opt in to the lightbox effect.

    There is also an open GitHub issue in relation to the plugins default lightbox configuration for indivudal images:
    https://github.com/ampproject/amp-wp/issues/5122

    Let me know if you have any further queries on this.

    As we haven’t received a response, I’ll mark this as resolved. Feel free to open a new support topic if you continue to encounter issues, or reopen this topic and we’d be happy to assist. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter to change html output featured image’ is closed to new replies.