mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-17 20:15:08 +00:00
Add a filter in wp_get_attachment_image_src()
called attachment_image_src
.
Props eclev91, MikeHansenMe. Fixes #32363. Built from https://develop.svn.wordpress.org/trunk@32866 git-svn-id: http://core.svn.wordpress.org/trunk@32837 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cfe78e0e95
commit
ec6dfc7f2b
@ -693,11 +693,9 @@ function get_intermediate_image_sizes() {
|
||||
* @return false|array Returns an array (url, width, height), or false, if no image is available.
|
||||
*/
|
||||
function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) {
|
||||
|
||||
// get a thumbnail or intermediate image if there is one
|
||||
if ( $image = image_downsize($attachment_id, $size) )
|
||||
return $image;
|
||||
|
||||
$image = image_downsize( $attachment_id, $size );
|
||||
if ( ! $image ) {
|
||||
$src = false;
|
||||
|
||||
if ( $icon && $src = wp_mime_type_icon( $attachment_id ) ) {
|
||||
@ -707,9 +705,23 @@ function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon
|
||||
$src_file = $icon_dir . '/' . wp_basename( $src );
|
||||
@list( $width, $height ) = getimagesize( $src_file );
|
||||
}
|
||||
if ( $src && $width && $height )
|
||||
return array( $src, $width, $height );
|
||||
return false;
|
||||
|
||||
if ( $src && $width && $height ) {
|
||||
$image = array( $src, $width, $height );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Filter the image src result
|
||||
*
|
||||
* @since 4.3.0
|
||||
*
|
||||
* @param array|false $image Either array with src, width & height, icon src, or false.
|
||||
* @param int $attachment_id Image attachment ID.
|
||||
* @param string|array $size Optional. Registered image size to retrieve the source for or a flat
|
||||
* array of height and width dimensions. Default 'thumbnail'.
|
||||
* @param bool $icon Optional. Whether the image should be treated as an icon. Default false.
|
||||
*/
|
||||
return apply_filters( 'attachment_image_src', $image, $attachment_id, $size, $icon );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.3-alpha-32865';
|
||||
$wp_version = '4.3-alpha-32866';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user