Media: Move `wp_get_original_image_path()` to `wp-content/post.php` to make it easier to access from plugins.
Props pbiron. See #47873. Built from https://develop.svn.wordpress.org/trunk@46353 git-svn-id: http://core.svn.wordpress.org/trunk@46152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7d667995b4
commit
38e6958698
|
@ -1034,40 +1034,3 @@ function _copy_image_file( $attachment_id ) {
|
||||||
|
|
||||||
return $dst_file;
|
return $dst_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the path to an uploaded image.
|
|
||||||
*
|
|
||||||
* Similar to `get_attached_file()` however some images may have been
|
|
||||||
* processed after uploading to make them "web ready".
|
|
||||||
* In this case this function returns the path to the originally uploaded image file.
|
|
||||||
*
|
|
||||||
* @since 5.3.0
|
|
||||||
*
|
|
||||||
* @param int $attachment_id Attachment ID.
|
|
||||||
* @return string|false Path to the original image file or false if the attachment is not an image.
|
|
||||||
*/
|
|
||||||
function wp_get_original_image_path( $attachment_id ) {
|
|
||||||
if ( ! wp_attachment_is_image( $attachment_id ) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$image_meta = wp_get_attachment_metadata( $attachment_id );
|
|
||||||
$image_file = get_attached_file( $attachment_id );
|
|
||||||
|
|
||||||
if ( empty( $image_meta['original_image'] ) ) {
|
|
||||||
$original_image = $image_file;
|
|
||||||
} else {
|
|
||||||
$original_image = path_join( dirname( $image_file ), $image_meta['original_image'] );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the path to the original image.
|
|
||||||
*
|
|
||||||
* @since 5.3.0
|
|
||||||
*
|
|
||||||
* @param string $original_image Path to original image file.
|
|
||||||
* @param int $attachment_id Attachment ID.
|
|
||||||
*/
|
|
||||||
return apply_filters( 'wp_get_original_image_path', $original_image, $attachment_id );
|
|
||||||
}
|
|
||||||
|
|
|
@ -7140,3 +7140,41 @@ function get_available_post_mime_types( $type = 'attachment' ) {
|
||||||
$types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
|
$types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
|
||||||
return $types;
|
return $types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the path to an uploaded image file.
|
||||||
|
*
|
||||||
|
* Similar to `get_attached_file()` however some images may have been processed after uploading
|
||||||
|
* to make them suitable for web use. In this case the attached "full" size file is usually replaced
|
||||||
|
* with a scaled down version of the original image. This function always returns the path
|
||||||
|
* to the originally uploaded image file.
|
||||||
|
*
|
||||||
|
* @since 5.3.0
|
||||||
|
*
|
||||||
|
* @param int $attachment_id Attachment ID.
|
||||||
|
* @return string|false Path to the original image file or false if the attachment is not an image.
|
||||||
|
*/
|
||||||
|
function wp_get_original_image_path( $attachment_id ) {
|
||||||
|
if ( ! wp_attachment_is_image( $attachment_id ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$image_meta = wp_get_attachment_metadata( $attachment_id );
|
||||||
|
$image_file = get_attached_file( $attachment_id );
|
||||||
|
|
||||||
|
if ( empty( $image_meta['original_image'] ) ) {
|
||||||
|
$original_image = $image_file;
|
||||||
|
} else {
|
||||||
|
$original_image = path_join( dirname( $image_file ), $image_meta['original_image'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the path to the original image.
|
||||||
|
*
|
||||||
|
* @since 5.3.0
|
||||||
|
*
|
||||||
|
* @param string $original_image Path to original image file.
|
||||||
|
* @param int $attachment_id Attachment ID.
|
||||||
|
*/
|
||||||
|
return apply_filters( 'wp_get_original_image_path', $original_image, $attachment_id );
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3-beta1-46352';
|
$wp_version = '5.3-beta1-46353';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue