wp_prepare_attachment_for_js( int|WP_Post $attachment ): array|null
- Since
- 3.5.0
- Source
wp-includes/media.php:4648
Compatibility
- WordPress
- since 3.5.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$attachmentint|WP_Post- Attachment ID or object.
Return value
array|null- Array of attachment details, or null if the parameter does not correspond to an attachment.
$altstringAlt text of the attachment.$authorstringID of the attachment author, as a string.$authorNamestringName of the attachment author.$captionstringCaption for the attachment.$compatarrayContaining item and meta.$contextstringContext, whether it's used as the site icon for example.$dateintUploaded date, timestamp in milliseconds.$dateFormattedstringFormatted date (e.g. June 29, 2018).$descriptionstringDescription of the attachment.$editLinkstringURL to the edit page for the attachment.$filenamestringFile name of the attachment.$filesizeHumanReadablestringFilesize of the attachment in human readable format (e.g. 1 MB).$filesizeInBytesintFilesize of the attachment in bytes.$heightintIf the attachment is an image, represents the height of the image in pixels.$iconstringIcon URL of the attachment (e.g. /wp-includes/images/media/archive.png).$idintID of the attachment.$linkstringURL to the attachment.$menuOrderintMenu order of the attachment post.$metaarrayMeta data for the attachment.$mimestringMime type of the attachment (e.g. image/jpeg or application/zip).$modifiedintLast modified, timestamp in milliseconds.$namestringName, same as title of the attachment.$noncesarrayNonces for update, delete and edit.$orientationstringIf the attachment is an image, represents the image orientation (landscape or portrait).$sizesarrayIf the attachment is an image, contains an array of arrays for the images sizes: thumbnail, medium, large, and full.$statusstringPost status of the attachment (usually 'inherit').$subtypestringMime subtype of the attachment (usually the last part, e.g. jpeg or zip).$titlestringTitle of the attachment (usually slugified file name without the extension).$typestringType of the attachment (usually first part of the mime type, e.g. image).$uploadedTointParent post to which the attachment was uploaded.$uploadedToLinkstringURL to the edit page of the parent post of the attachment.$uploadedToTitlestringPost title of the parent of the attachment.$urlstringDirect URL to the attachment file (from wp-content).$widthintIf the attachment is an image, represents the width of the image in pixels.
Performance profile
How much work a call to wp_prepare_attachment_for_js() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Scales with input
- Instructions
- 190–325
- Plugin surface
- 3 hooks
- Called by
- 7
Reaches the database via get_post().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 675.
Third-party callbacks on 'image_size_names_choose', 'image_downsize', 'wp_prepare_attachment_for_js' run inside this call, and their cost is not bounded by anything here.
7 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- querycontent query
get_post()called directly - hookthird-party callbacks
apply_filters()called directly - optionoption read or write
get_option()one call below wp_prepare_attachment_for_js() - cacheobject cache
wp_cache_get()one call below wp_prepare_attachment_for_js()
Further down the call graph this can also reach serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 48 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_prepare_attachment_for_js() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && !function_exists() | 190 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() | 196–199 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() | 198 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && function_exists() | 204–207 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !function_exists() | 230–241 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) | 236–250 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) | 238–249 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && function_exists() | 244–258 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && !is_array($response_image_thumb) && !function_exists() | 267–274 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && !is_array($response_image_thumb) | 273–283 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && !is_array($response_image_thumb) | 275–282 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && empty($id) && !function_exists() | 276–283 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_mime_type_icon(), compact(), compact(), function_exists(), function_exists(), apply_filters() |
36 further outcomes, up to 325 instructions
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && !is_array($response_image_thumb) && !function_exists() | 277–284 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && !is_array($response_image_thumb) && !function_exists() | 279–286 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && is_array($response_image_thumb) && !function_exists() | 280–287 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && !is_array($response_image_thumb) && function_exists() | 281–291 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && empty($id) | 282–292 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_mime_type_icon(), compact(), compact(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && !is_array($response_image_thumb) | 283–293 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && empty($id) | 284–291 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_mime_type_icon(), compact(), compact(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && !is_array($response_image_thumb) | 285–295 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && !is_array($response_image_thumb) | 285–292 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && is_array($response_image_thumb) | 286–296 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && empty($id) && !function_exists() | 286–293 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_mime_type_icon(), compact(), compact(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && !is_array($response_image_thumb) | 287–294 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && is_array($response_image_thumb) | 288–295 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && !is_array($response_image_thumb) && !function_exists() | 289–295 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && is_array($response_image_thumb) && !function_exists() | 290–297 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && empty($id) && function_exists() | 290–300 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_mime_type_icon(), compact(), compact(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && !is_array($response_image_thumb) && function_exists() | 291–301 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && is_array($response_image_thumb) && !function_exists() | 292–299 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && empty($id) | 292–302 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_mime_type_icon(), compact(), compact(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && !is_array($response_image_thumb) && function_exists() | 293–303 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && is_array($response_image_thumb) && function_exists() | 294–304 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && empty($id) | 294–301 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_mime_type_icon(), compact(), compact(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && !is_array($response_image_thumb) | 295–304 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && is_array($response_image_thumb) | 296–305 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && !is_array($response_image_thumb) | 297–303 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && is_array($response_image_thumb) | 298–308 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && is_array($response_image_thumb) | 298–304 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && is_array($response_image_thumb) | 300–307 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && empty($id) && function_exists() | 300–310 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_mime_type_icon(), compact(), compact(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && is_array($response_image_thumb) && !function_exists() | 302–308 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), function_exists(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && !is_array($response_image_thumb) && function_exists() | 303–312 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && !is_array($response_image_full) && is_array($response_image_thumb) && function_exists() | 304–313 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !isset($meta) && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && is_array($response_image_thumb) && function_exists() | 306–316 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && is_array($response_image_thumb) | 308–317 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), function_exists(), get_media_states(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && is_array($response_image_thumb) | 310–316 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), get_compat_media_markup(), function_exists(), apply_filters() |
!->exists() && !$attachment && !is_string($attached_file) && !current_user_can() && empty($value) && !empty($id) && is_array($response_image_full) && is_array($response_image_thumb) && function_exists() | 316–325 | get_post(), wp_get_attachment_metadata(), wp_get_attachment_url(), wp_basename(), get_attached_file(), wp_basename(), esc_url_raw(), get_attachment_link(), get_post_meta(), strtotime(), strtotime(), wp_mime_type_icon(), __(), mysql2date(), id(), ->exists(), __(), get_attached_file(), get_post_meta(), current_user_can(), current_user_can(), __(), __(), __(), __(), thumbnail(), sizes(), human_readable_duration(), wp_get_attachment_id3_keys(), get_post_thumbnail_id(), wp_get_attachment_image_src(), esc_url_raw(), wp_get_attachment_image_src(), esc_url_raw(), function_exists(), get_compat_media_markup(), function_exists(), get_media_states(), apply_filters() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 673 | 190–325 | 56 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 675 | 190–325 | 56 | |
| 8.4 | 675 | 190–325 | 56 | 11 fewer instructions than PHP 8.3 |
| 8.3 | 686 | 196–334 | 56 | |
| 8.2 | 686 | 196–334 | 56 | |
| 8.1 | 686 | 196–334 | 56 | 4 fewer instructions than PHP 7.4 |
| 7.4 | 690 | 197–335 | 56 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 3
3 hooks fire while wp_prepare_attachment_for_js() runs, in this order:
- apply_filters( image_size_names_choose )filterline 4749 (+101 into the body)
Filters the names and labels of the default image sizes.
- apply_filters( image_downsize )filterline 4769 (+121 into the body)
Filters whether to preempt the output of image_downsize().
- apply_filters( wp_prepare_attachment_for_js )filterline 4904 (+256 into the body)
Filters the attachment data prepared for JavaScript.
Uses · 30
- get_post()Retrieves post data given a post ID or post object.
- wp_get_attachment_metadata()Retrieves attachment metadata for attachment ID.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- wp_get_attachment_url()Retrieves the URL for an attachment.
- wp_basename()i18n-friendly version of basename().
- get_attached_file()Retrieves attached file path based on attachment ID.
- esc_url_raw()Sanitizes a URL for database or redirect usage.
- get_attachment_link()Retrieves the permalink for an attachment.
- get_post_meta()Retrieves a post meta field for the given post ID.
- wp_mime_type_icon()Retrieves the icon for a MIME type or attachment.
- mysql2date()Converts given MySQL date string into a different format.
- __()Retrieves the translation of $text.
Show all 30
- get_bloginfo()Retrieves information about the current site.
- get_edit_user_link()Retrieves the edit user link.
- current_user_can()Returns whether the current user has the specified capability.
- get_edit_post_link()Retrieves the edit post link for post.
- wp_filesize()Wrapper for PHP filesize with filters and casting the result as an integer.
- size_format()Converts a number of bytes to the largest unit the bytes will fit into.
- wp_create_nonce()Creates a cryptographic token tied to a specific action, user, user session, and window of time.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- image_constrain_size_for_editor()Scales down the default size of an image.
- wp_get_original_image_url()Retrieves the URL to an original attachment image.
- wp_get_original_image_path()Retrieves the path to an uploaded image file.
- human_readable_duration()Converts a duration to human readable format.
- wp_get_attachment_id3_keys()Returns useful keys to use to lookup data from an attachment's stored metadata.
- get_post_thumbnail_id()Retrieves the post thumbnail ID.
- wp_get_attachment_image_src()Retrieves an image to represent an attachment.
- get_compat_media_markup()Retrieves the media markup for an attachment.
- get_media_states()Retrieves an array of media states from an attachment.
- WP_User::__construct()Constructor.
Used by · 7
- WP_Customize_Media_Control::to_json()Refresh the parameters passed to the JavaScript via JSON.
- WP_Customize_Upload_Control::to_json()Refresh the parameters passed to the JavaScript via JSON.
- wp_ajax_crop_image()Handles cropping an image via AJAX.
- wp_ajax_get_attachment()Handles getting an attachment via AJAX.
- wp_ajax_media_create_image_subsizes()Handles creating missing image sub-sizes for just uploaded images via AJAX.
- wp_ajax_save_attachment_compat()Handles saving backward compatible attachment attributes via AJAX.
- wp_ajax_upload_attachment()Handles uploading attachments via AJAX.
Source code
function wp_prepare_attachment_for_js( $attachment ) { $attachment = get_post( $attachment ); if ( ! $attachment ) { return null; } if ( 'attachment' !== $attachment->post_type ) { return null; } $meta = wp_get_attachment_metadata( $attachment->ID ); if ( str_contains( $attachment->post_mime_type, '/' ) ) { list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); } else { list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); } $attachment_url = wp_get_attachment_url( $attachment->ID ); $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url ); $response = array( 'id' => $attachment->ID, 'title' => $attachment->post_title, 'filename' => wp_basename( get_attached_file( $attachment->ID ) ), 'url' => esc_url_raw( $attachment_url ), 'link' => get_attachment_link( $attachment->ID ), 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), 'author' => $attachment->post_author, 'description' => $attachment->post_content, 'caption' => $attachment->post_excerpt, 'name' => $attachment->post_name, 'status' => $attachment->post_status, 'uploadedTo' => $attachment->post_parent, 'date' => strtotime( $attachment->post_date_gmt ) * 1000, 'modified' => strtotime( $attachment->post_modified_gmt ) * 1000, 'menuOrder' => $attachment->menu_order, 'mime' => $attachment->post_mime_type, 'type' => $type, 'subtype' => $subtype, 'icon' => wp_mime_type_icon( $attachment->ID, '.svg' ), 'dateFormatted' => mysql2date( __( 'F j, Y' ), $attachment->post_date ), 'nonces' => array( 'update' => false, 'delete' => false, 'edit' => false, ), 'editLink' => false, 'meta' => false, ); $author = new WP_User( $attachment->post_author ); if ( $author->exists() ) { $author_name = $author->display_name ? $author->display_name : $author->nickname; $response['authorName'] = html_entity_decode( $author_name, ENT_QUOTES, get_bloginfo( 'charset' ) ); $response['authorLink'] = get_edit_user_link( $author->ID ); } else { $response['authorName'] = __( '(no author)' ); } if ( $attachment->post_parent ) { $post_parent = get_post( $attachment->post_parent ); if ( $post_parent && current_user_can( 'read_post', $attachment->post_parent ) ) { $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' ); $response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' ); } } $attached_file = get_attached_file( $attachment->ID ); if ( isset( $meta['filesize'] ) && is_numeric( $meta['filesize'] ) && (int) $meta['filesize'] > 0 ) { $bytes = (int) $meta['filesize']; } elseif ( is_string( $attached_file ) && '' !== $attached_file && is_readable( $attached_file ) ) { $bytes = wp_filesize( $attached_file ); } else { $bytes = ''; } if ( $bytes ) {Changelog
Introduced in 3.5.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
array|void to array|null.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/media.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.