Gets the attachment’s original file name.
Parameters
$attachment_idintrequired- Attachment ID.
Source
protected function get_attachment_filename( int $attachment_id ): ?string {
$path = wp_get_original_image_path( $attachment_id );
if ( $path ) {
return wp_basename( $path );
}
$path = get_attached_file( $attachment_id );
if ( $path ) {
return wp_basename( $path );
}
return null;
}
Changelog
| Version | Description |
|---|---|
| 7.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.