Attachments (Media files) (category)

get_attached_file()

Gets the absolute (server) path of the attachment (attached file) by the provided attachment ID.

get_attached_media()

Gets attachments (images, videos, audio) attached to a post. Retrieves data objects in the form of an array.

get_attachment_link()

Gets the URL of the media file page on the site (front-end).

get_children()

Retrieve all children (attachments, revisions, or sub-pages) of the post parent ID. It works similar to get_posts().

get_post_mime_type()

Retrieves the mime type of attachment posts (images, files, etc.), based on the provided ID.

is_local_attachment()

Determines whether the given URL is an attachment page of the current site.

the_attachment_link()

Outputs an HTML A tag link to the file attached to the post (attachment) or the page of that file in the template.

wp_attachment_is()

Checks if the specified attachment is: an image, audio, or video. Conditional tag.

wp_delete_attachment()

Deletes a WordPress attachment (media library file, attached file). The file is physically deleted.

wp_get_attachment_link()

Gets a link to the attachment file or WP attachment page. Returns the <a> tag.

wp_get_attachment_url()

Gets the URL of the attachment by the provided attachment ID. Gets the link to the file.

wp_get_original_image_path()

Gets the path of the original image (not its resized copy) by the specified attachment ID.

wp_get_original_image_url()

Gets the URL of the original image (not its resized copy) by the specified attachment ID.

wp_insert_attachment()

Adds a media file (attachment) to the WordPress media library. The file is not physically added — the function creates a post in the wp_posts table in the database and returns the ID of the created post.

Thumbnails

add_image_size()

Registers a new image size (thumbnail).

delete_post_thumbnail()

Deletes the post thumbnail by post ID. The meta-field is deleted, not the thumbnail file itself.

get_intermediate_image_sizes()

Gets an array of the names of all intermediate image sizes registered for the site. You can also get all size data.

get_post_thumbnail_id()

Gets the ID of the current (or specified) post thumbnail (featured image). Gets ID of WP attachment (image).

get_the_post_thumbnail()

Gets the IMG tag of the post thumbnail (if exists).

get_the_post_thumbnail_caption()

Gets the post thumbnail caption (description).

get_the_post_thumbnail_url()

Gets the thumbnail URL specified for the post. If there is no post thumbnail, it returns false.

has_image_size()

Checks whether the specified image size exists.

has_post_thumbnail()

Checks if the specified post has a thumbnail image. Conditional tag.

image_get_intermediate_size()

Gets an array of image-attachment data of the specified size: thumbnail, medium etc., if it exists.

remove_image_size()

Removes a previously registered image size by it name. The new image size is registered with add_image_size().

set_post_thumbnail()

Sets the post thumbnail based on the provided post ID and attachment (media file) ID. If the specified attachment does not exist in the database, the function will remove the post thumbnail.

set_post_thumbnail_size()

Sets the default size of the post thumbnail.

the_post_thumbnail()

Outputs the HTML code (<img> tag) for the thumbnail of the current post.

the_post_thumbnail_caption()

Displays the post thumbnail caption.

the_post_thumbnail_url()

Outputs the URL of the current post's thumbnail. If there is no thumbnail, it returns NULL (nothing will be output). Used in the WordPress loop.

wp_get_additional_image_sizes()

Gets data of all additionally registered image sizes (thumbnails).

wp_get_attachment_thumb_url()

Retrieves the URL of the attachment image with size thumbnail.

wp_get_image_editor()

Returns a WP_Image_Editor object with the specified image. Used for resizing an image (creating thumbnails) and editing the image.

wp_get_registered_image_subsizes()

Gets the data (width, height, crop) of the currently registered image sizes.

Rarely used

attachment_url_to_postid()

Trying to get the attachment ID (image from the media library) by the specified attachment URL.

get_allowed_mime_types()

Gets the list of allowed file types. Returns an array: extension => mime/type.

wp_get_audio_extensions()

Gets an array of audio formats supported in WordPress. Gets file extensions.

wp_get_avif_info()

Extracts metadata of the specified AVIF image. Such as: width, height, color depth and number of channels.

wp_get_ext_types()

Gets a list of basic file extensions by type. For example, image extensions, audio file extensions, video file extensions, etc.

wp_get_video_extensions()

Retrieves an array of supported video formats in WordPress. Retrieves file extensions.

wp_getimagesize()

Gets the image dimensions and other related information.

wp_read_image_metadata()

Gathers an array of useful image metadata from the exif and iptc file metadata.

Metadata (postmeta)

delete_post_meta_by_key()

Deletes all meta-fields (custom fields) of all posts by the specified meta-field key.

wp_generate_attachment_metadata()

Generates metadata for the image attachment and creates intermediate copies of the image - thumbnails of all registered sizes.

wp_get_attachment_metadata()

Retrieves the metadata for an attached file (attachment).

wp_maybe_generate_attachment_metadata()

Creates attachment metadata if it is missing; otherwise, does nothing.

wp_read_audio_metadata()

Gets all data about an audio file from its ID3 tags. This includes all available data: format, channels, bitrate, size, MIME type, duration, year, album, artist, comment, picture, etc.

wp_update_attachment_metadata()

Updates attachment (media file) metadata.

Images

file_is_displayable_image()

Checks if the file is an image (if it is suitable for display on the page). Conditional tag.

image_downsize()

Gets an array of image data for the specified size: URL, width and height of the attachment image.

next_image_link()

Displays a link to the next image attached to the post.

previous_image_link()

Outputs a link to the previous image attached to the post. Returns the HTML code of the link.

wp_attachment_is_image()

Determines whether the specified post is WordPress attachment image. A conditional tag.

wp_get_attachment_caption()

Retrieves the caption of specified attachment.

wp_get_attachment_image()

Gets the <img> tag of the image of the specified attachment (file attached to the post).

wp_get_attachment_image_sizes()

Gets the size values of the specified attachment image for the sizes attribute.

wp_get_attachment_image_src()

Gets an array of data for the specified image: URL, width, height of the attachment image.

wp_get_attachment_image_srcset()

Gets the value of the srcset attribute for the <img> tag. The value will contain the names of all sizes of the specified image in the format: image.jpg 1x, image-sm.jpg 640w.

wp_get_attachment_image_url()

Gets the URL of the attachment image by the provided image ID. You can also specify the size of the image for which you need to get the URL.

wp_get_image_mime()

Gets the real MIME type of an image file.

Gallery

get_post_galleries()

Gets all galleries from the text of the specified post. Searches for [[gallery]] shortcodes in the text, processes them and returns an array of gallery image data.

get_post_galleries_images()

Gets all image URLs from galleries in the specified post text, if galleries are present in the text.

get_post_gallery()

Gets the first gallery from the text of the specified post. Searches for the [[gallery]] shortcode in the text, processes it and returns an array of gallery image data.

get_post_gallery_images()

Retrieves an array of image URLs that belong to the first gallery of the specified post.

Upload/Download

media_handle_sideload()

Uploads a file to the WordPress media library from the provided array with file data, similar to media_handle_upload().

media_handle_upload()

Uploads the file provided in the form to the WordPress uploads folder and creates a record of the file in the database (adds the file to the WP media library).

media_sideload_image()

Uploads an image to the WP media library from the specified URL and attaches it to a post.

wp_check_filetype()

Gets the file extension and MIME type by the given filename (path). Used to check whether the specified file type is allowed to be uploaded to the site.

wp_check_filetype_and_ext()

Checks if the specified file is allowed to be uploaded based on its actual MIME type.

wp_get_upload_dir()

Retrieves data about the uploads folder (upload) as an array of parameters.

wp_handle_sideload()

Moves a temporary file to the uploads folder.

wp_handle_upload()

Processes file upload via $_FILES. Checks the file and moves it to the UPLOADS folder.

wp_max_upload_size()

Gets the maximum file size (in bytes) that is allowed to be uploaded in WordPress.

wp_unique_filename()

Makes a file name unique. Used before saving a file into the specified folder to change its name if a file with that name already exists.

wp_upload_bits()

Creates a file with the specified content in the uploads folder (upload). Returns the uploaded file data. Does not store file data in the DB.

wp_upload_dir()

Gets upload directory data: path, URL.