Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @gustavomelki,

    You can use the sanitizer to convert img tags to amp-img.

    For example, This is how we sanitize images in comments:

    $sanitizer = new AMPFORWP_Content( $comment_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array() ) ) );

    Let me know if that helps or not.

    I got this to work with a little experimentation and, honestly, guessing.

    $sanitizer = new AMPFORWP_Content( wp_get_attachment_image( get_field('image'), 'full' ), array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array() ) ) );
    
    echo $sanitizer->get_amp_content();

    My image field is set to output the ID. If you’re not doing that, you’ll have to adjust your input to wp_get_attachment_image accordingly.

    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @gustavomelki,

    Are you still having the same issue?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘convert img to amp-img in acf custom field’ is closed to new replies.