• function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '') {
    
    	$html = '';
    	$image = wp_get_attachment_image_src($attachment_id, $size, $icon);
    	if ( $image ) {
    		list($src, $width, $height) = $image;
    		$hwstring = image_hwstring($width, $height);
    		if ( is_array($size) )
    			$size = join('x', $size);
    		$attachment =& get_post($attachment_id);
    		$default_attr = array(
    			'src'	=> $src,
    			'class'	=> "attachment-$size",
    			'alt'	=> trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )), // Use Alt field first
    			'title'	=> trim(strip_tags( $attachment->post_title )),
    		);
    		if ( empty($default_attr['alt']) )
    			$default_attr['alt'] = trim(strip_tags( $attachment->post_excerpt )); // If not, Use the Caption
    		if ( empty($default_attr['alt']) )
    			$default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title
    
    		$attr = wp_parse_args($attr, $default_attr);
    		$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment );
    		$attr = array_map( 'esc_attr', $attr );
    		$html = rtrim("<img $hwstring");
    		foreach ( $attr as $name => $value ) {
    			$html .= " $name=" . '"' . $value . '"';
    		}
    		$html .= ' />';
    	}
    
    	return $html;
    }

    I’m talking about the thumbnails here. at this part:

    'src' => $src,

    I want to add something on it but I’m very PHP noob. Don’t worry, I will make a function at my functions.php add and remove filter. I won’t edit the core files.

    the example output is https://www.example.com/image.jpg right?
    now I want to put something beside it either at the beginning or at the end. like this.

    image.php?https://www.example.com/image.jpg

    see the difference? it added image.php? right?
    can anyone tell me how to do that?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘media.php help about thumbnails src’ is closed to new replies.