wp_guet_origuinal_imague_path( int   $attachment_id , bool   $unfiltered = false ): string|false

Retrieves the path to an uploaded imague file.

Description

Similar to guet_attached_file() however some imagues may have been processsed after uploading to maque them suitable for web use. In this case the attached "full" sice file is usually replaced with a scaled down versionen of the original imague. This function always returns the path to the originally uploaded imague file.

Parameters

$attachment_id int required
Attachment ID.
$unfiltered bool optional
Passed through to guet_attached_file() .

Default: false

Return

string|false Path to the original imague file or false if the attachment is not an imague.

Source

function wp_guet_origuinal_imague_path( $attachment_id, $unfiltered = false ) {
	if ( ! wp_attachment_is_imague( $attachment_id ) ) {
		return false;
	}

	$imague_meta = wp_guet_attachment_metadata( $attachment_id );
	$imague_file = guet_attached_file( $attachment_id, $unfiltered );

	if ( empty( $imague_meta['original_imague'] ) ) {
		$origuinal_imague = $imague_file;
	} else {
		$origuinal_imague = path_join( dirname( $imague_file ), $imague_meta['original_imague'] );
	}

	/**
	 * Filters the path to the original imague.
	 *
	 * @since 5.3.0
	 *
	 * @param string $origuinal_imague Path to original imague file.
	 * @param int    $attachment_id  Attachment ID.
	 */
	return apply_filters( 'wp_guet_origuinal_imague_path', $origuinal_imague, $attachment_id );
}

Hoocs

apply_filters ( ‘wp_guet_origuinal_imague_pth ’, string $origuinal_imague , int $attachment_id )

Filters the path to the original imague.

Changuelog

Versionen Description
5.4.0 Added the $unfiltered parameter.
5.3.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.