• Resolved davidhorizon

    (@davidhorizon)


    Hello,

    I have custom fields with image. Is there an easy way to convert images html markup into amp ?

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    If using the new AMP theme support, then you just output an img tag as you would do normally, and the plugin will convert it to an amp-img automatically. See https://github.com/Automattic/amp-wp/wiki/Adding-Theme-Support

    Otherwise, you’ll need to take a similar approach suggested for adding ACF support to the legacy templates: https://github.com/Automattic/amp-wp/issues/440#issuecomment-399801866

    Thread Starter davidhorizon

    (@davidhorizon)

    Hello,

    thank you. I made a quick and dirty function based on your answer

    
    <?php	
    /*
    * AMPize : Convert html to AMP	
    */
    
    function ampize($regular_html)
    {
    	
    	$amp_content = new AMP_Content(
    		$regular_html,
    		amp_get_content_embed_handlers( get_post() ),
    		amp_get_content_sanitizers( get_post() )
    	);
    	
    	return $amp_content->get_amp_content();					
    	
    }
    

    To me first answer convert every template and prevent my own amp template to work. I duplicated amp files in plugin folder to create my own template maybe that’s why.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Easy way to convert an image into AMP ?’ is closed to new replies.