Title: Modify thumbnail output html img src with AMP-img src
Last modified: August 31, 2016

---

# Modify thumbnail output html img src with AMP-img src

 *  [parazi7u](https://wordpress.org/support/users/parazi7u/)
 * (@parazi7u)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/replace-4/)
 * Hi! I need to replace the default thumbnail output html: <img src=”image.png”
   alt=”” …/> with <amp-img src=”image.png” ….> nothing more. Please help me. I 
   want to develop my theme for Google Mobile AMP. thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [10 years, 3 months ago](https://wordpress.org/support/topic/replace-4/#post-7002968)
 * Hi there!
 * Not sure which thumbnail you are looking to modify but have you looked into what
   image functions WordPress does have? One that comes to mind is:
    [https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/)
 * If you are looking for just the post thumbnail you can try using the `post_thumbnail_html`
   filter:
    [https://developer.wordpress.org/reference/hooks/post_thumbnail_html/](https://developer.wordpress.org/reference/hooks/post_thumbnail_html/)
 * Hope that helps you out a bit!
 *  [animaleja32](https://wordpress.org/support/users/animaleja32/)
 * (@animaleja32)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/replace-4/#post-8440352)
 * I have the same question as parazi7u…
 * I got this snippet… I think I’m close, but not quite there yet. Any idea on how
   to convert  into <amp-img>?
 * function isa_amp_featured_img( $size = ‘medium’ ) {
 *  global $post;
 *  if ( has_post_thumbnail( $post->ID ) ) {
 *  $thumb_id = get_post_thumbnail_id( $post->ID );
    $img = wp_get_attachment_image_src(
   $thumb_id, $size ); $img_src = $img[0]; $w = $img[1]; $h = $img[2];
 *  $alt = get_post_meta($post->ID, ‘_wp_attachment_image_alt’, true);
 *  if(empty($alt)) {
    $attachment = get_post( $thumb_id ); $alt = trim(strip_tags(
   $attachment->post_title ) ); } ?> <amp-img id=”feat-img” src=”<?php echo esc_url(
   $img_src ); ?>” <?php if ( $img_srcset = wp_get_attachment_image_srcset( $thumb_id,
   $size ) ) { ?> srcset=”<?php echo esc_attr( $img_srcset ); ?>” <?php } ?> alt
   =”<?php echo esc_attr( $alt ); ?>” width=”<?php echo $w; ?>” height=”<?php echo
   $h; ?>”> </amp-img> <?php } }
 * function my_amp_set_custom_template( $file, $type, $post ) {
    if ( ‘single’ =
   == $type ) { $file = get_stylesheet_directory() . ‘/amp/single.php’; } return
   $file; } add_filter( ‘amp_post_template_file’, ‘my_amp_set_custom_template’, 
   10, 3 );

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Modify thumbnail output html img src with AMP-img src’ is closed to new
replies.

## Tags

 * [Google AMP](https://wordpress.org/support/topic-tag/google-amp/)
 * [html](https://wordpress.org/support/topic-tag/html/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [animaleja32](https://wordpress.org/support/users/animaleja32/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/replace-4/#post-8440352)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
