Viewing 4 replies - 1 through 4 (of 4 total)
  • Dear Ischatzkin,

    Can you provide a code example ? I have been using

    echo '<img src="' . esc_url( wp_get_attachment_image_url( $image, 'small', true ) ) . '" >';

    but i cannot change the image size to small or thumbnail. It always stay on full size.

    thanks

    Try this :

    $image_id = get_term_meta( get_queried_object()->term_id, 'image', true );
    
    if ( ! empty( $image_id ) ) {
    
    	$image_atts = wp_get_attachment_image_src( $image_id, 'full' );
    
    	$image_url = $image_atts[0];
    
        	echo '<img src="' . esc_url( $image_atts[0] ) . '" />';
    }

    Thanks but that doesn’t work for me. I get this message :

    Trying to get property of non-object in … on line 36

    Plugin Author John James Jacoby

    (@johnjamesjacoby)

    I think a few people are having some similar issues, so I’ll be including helper functions in a future release to make this a bit easier to pull off theme-side.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘need wp_get_attachment_image_src’ is closed to new replies.