diff --git i/src/wp-includes/post-functions.php w/src/wp-includes/post-functions.php
index 3338447..58fe5f9 100644
|
i
|
w
|
function wp_get_attachment_url( $post_id = 0 ) { |
| 4857 | 4857 | * Retrieve thumbnail for an attachment. |
| 4858 | 4858 | * |
| 4859 | 4859 | * @since 2.1.0 |
| | 4860 | * @since 4.4.0 `$post` can be a post ID or WP_Post object. `$size` is a parameter. |
| | 4861 | * @since 4.4.0 `$size` is an optional parameter, allow to specify the attachment thumbnail. |
| 4860 | 4862 | * |
| 4861 | | * @param int $post_id Optional. Attachment ID. Default 0. |
| 4862 | | * @return string|false False on failure. Thumbnail file path on success. |
| | 4863 | * @param null|int|WP_Post $post Optional. Attachment ID or WP_Post object. Default null. |
| | 4864 | * @param string $size Optional. Attachment size. Default thumb. |
| | 4865 | * |
| | 4866 | * @return false|string False on failure. Thumbnail file path on success. |
| 4863 | 4867 | */ |
| 4864 | | function wp_get_attachment_thumb_file( $post_id = 0 ) { |
| 4865 | | $post_id = (int) $post_id; |
| 4866 | | if ( !$post = get_post( $post_id ) ) |
| | 4868 | function wp_get_attachment_thumb_file( $post = null, $size = 'thumb' ) { |
| | 4869 | $post = get_post( $post ); |
| | 4870 | if ( ! $post ) { |
| 4867 | 4871 | return false; |
| 4868 | | if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) |
| | 4872 | } |
| | 4873 | |
| | 4874 | $image_data = wp_get_attachment_metadata( $post->ID ); |
| | 4875 | if ( ! is_array( $image_data ) ) { |
| 4869 | 4876 | return false; |
| | 4877 | } |
| 4870 | 4878 | |
| 4871 | 4879 | $file = get_attached_file( $post->ID ); |
| | 4880 | $thumb_file = ''; |
| 4872 | 4881 | |
| 4873 | | if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) { |
| | 4882 | if( 'thumb' === $size ) { |
| | 4883 | $thumb_file = ! empty( $image_data['thumb'] ) ? str_replace( basename( $file ), $image_data['thumb'], $file ) : ''; |
| | 4884 | } elseif( isset( $image_data['sizes'][$size] ) ) { |
| | 4885 | $thumb_file = str_replace( basename( $file ), $image_data['sizes'][$size]['file'], $file ); |
| | 4886 | } |
| | 4887 | |
| | 4888 | if ( ! empty( $thumb_file ) && file_exists( $thumb_file ) ) { |
| 4874 | 4889 | /** |
| 4875 | 4890 | * Filter the attachment thumbnail file path. |
| 4876 | 4891 | * |
| 4877 | 4892 | * @since 2.1.0 |
| | 4893 | * @since 4.4.0 `$size` the specified size. |
| 4878 | 4894 | * |
| 4879 | | * @param string $thumbfile File path to the attachment thumbnail. |
| | 4895 | * @param string $thumb_file File path to the attachment thumbnail. |
| 4880 | 4896 | * @param int $post_id Attachment ID. |
| | 4897 | * @param string $size Attachment size. |
| 4881 | 4898 | */ |
| 4882 | | return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID ); |
| | 4899 | return apply_filters( 'wp_get_attachment_thumb_file', $thumb_file, $post->ID, $size ); |
| 4883 | 4900 | } |
| | 4901 | |
| 4884 | 4902 | return false; |
| 4885 | 4903 | } |
| 4886 | 4904 | |