Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_get_attachment_thumb_file ›

Seit2.1.0
Veraltetn/v
wp_get_attachment_thumb_file ( $post_id = 0 )
Parameter:
  • (int) $post_id Optional. Attachment ID. Default 0.
    Erforderlich: Nein
    Standard:
Gibt zurück:
  • (string|false) False on failure. Thumbnail file path on success.
Definiert in:
Codex:

Retrieve thumbnail for an attachment.



Quellcode

function wp_get_attachment_thumb_file( $post_id = 0 ) {
	$post_id = (int) $post_id;
	if ( ! $post = get_post( $post_id ) ) {
		return false;
	}
	if ( ! is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) {
		return false;
	}

	$file = get_attached_file( $post->ID );

	if ( ! empty( $imagedata['thumb'] ) && ( $thumbfile = str_replace( basename( $file ), $imagedata['thumb'], $file ) ) && file_exists( $thumbfile ) ) {
		/**
		 * Filters the attachment thumbnail file path.
		 *
		 * @since 2.1.0
		 *
		 * @param string $thumbfile File path to the attachment thumbnail.
		 * @param int    $post_id   Attachment ID.
		 */
		return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
	}
	return false;
}