Outil de recherche WordPress pour les développeurs et auteurs de thèmes



wp_get_original_image_path ›

Depuis5.3.0
Dépréciéen/a
wp_get_original_image_path ( $attachment_id )
Paramètres:
  • (int) $attachment_id Attachment ID.
    Requis: Oui
Retourne:
  • (string|false) Path to the original image file or false if the attachment is not an image.
Défini(e) dans:
Codex:

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.



Source

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 );
}