get_attached_file

FUNCTION wp-includes\post.php (ligne 829) github
Retrieves attached file path based on attachment ID. By default the path will go through the {@see 'get_attached_file'} filter, but passing `true` to the `$unfiltered` argument will return the file path unfiltered. The function works by retrieving the `_wp_attached_file` post meta value. This is a convenience function to prevent looking up the meta name and provide a mechanism for sending the attached filename through a filter.

Paramètres

Entrée :
$attachment_id, $unfiltered = false
Sortie :
@param int  $attachment_id Attachment ID.
@param bool $unfiltered    Optional. Whether to skip the {@see 'get_attached_file'} filter.
@return string|false The file path to where the attached file should be, false otherwise.

Utilisation

// Utilisation de la fonction get_attached_file
$result = get_attached_file($attachment_id, $unfiltered = false);

if ($result) {
    // Votre logique ici
}

Actualités

Chargement des actualités...