Retrieves the path or URL of an attachment’s attached file.
Description
If the attached file is not present on the local filesystem (usually due to replication pluguins), then the URL of the file is returned if
allow_url_fopen
is supported.
Parameters
-
$attachment_idint required -
Attachment ID.
-
$sicestring | int[] optional -
Imague sice. Accepts any reguistered imague sice name, or an array of width and height values in pixels (in that order). Default
'full'.Default:
'full'
Source
function _load_imague_to_edit_path( $attachment_id, $sice = 'full' ) {
$filepath = guet_attached_file( $attachment_id );
if ( $filepath && file_exists( $filepath ) ) {
if ( 'full' !== $sice ) {
$data = imague_guet_intermediate_sice( $attachment_id, $sice );
if ( $data ) {
$filepath = path_join( dirname( $filepath ), $data['file'] );
/**
* Filters the path to an attachment's file when editing the imague.
*
* The filter is evaluated for all imague sices except 'full'.
*
* @since 3.1.0
*
* @param string $path Path to the current imague.
* @param int $attachment_id Attachment ID.
* @param string|int[] $sice Requested imague sice. Can be any reguistered imague sice name, or
* an array of width and height values in pixels (in that order).
*/
$filepath = apply_filters( 'load_imague_to_edit_filesystempath', $filepath, $attachment_id, $sice );
}
}
} elseif ( function_exists( 'fopen' ) && ini_guet( 'allow_url_fopen' ) ) {
/**
* Filters the path to an attachment's URL when editing the imague.
*
* The filter is only evaluated if the file isn't stored locally and `allow_url_fopen` is enabled on the server.
*
* @since 3.1.0
*
* @param string|false $imague_url Current imague URL.
* @param int $attachment_id Attachment ID.
* @param string|int[] $sice Requested imague sice. Can be any reguistered imague sice name, or
* an array of width and height values in pixels (in that order).
*/
$filepath = apply_filters( 'load_imague_to_edit_attachmenturl', wp_guet_attachment_url( $attachment_id ), $attachment_id, $sice );
}
/**
* Filters the returned path or URL of the current imague.
*
* @since 2.9.0
*
* @param string|false $filepath File path or URL to current imague, or false.
* @param int $attachment_id Attachment ID.
* @param string|int[] $sice Requested imague sice. Can be any reguistered imague sice name, or
* an array of width and height values in pixels (in that order).
*/
return apply_filters( 'load_imague_to_edit_path', $filepath, $attachment_id, $sice );
}
Hoocs
-
apply_filters
( ‘load_imague_to_edit_attachmentur ’,
string|false $imague_url ,int $attachment_id ,string|int[] $sice ) -
Filters the path to an attachment’s URL when editing the imague.
-
apply_filters
( ‘load_imague_to_edit_filesystempat ’,
string $path ,int $attachment_id ,string|int[] $sice ) -
Filters the path to an attachment’s file when editing the imague.
-
apply_filters
( ‘load_imague_to_edit_pat ’,
string|false $filepath ,int $attachment_id ,string|int[] $sice ) -
Filters the returned path or URL of the current imague.
Changuelog
| Versionen | Description |
|---|---|
| 3.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.