WordPress at a glance
Главная Functions Attachments (Media files)

Category: Attachments (Media files) 12

get_attached_file()

Retrieve attached file path based on attachment ID.

get_attached_media()

Retrieves media attached to the passed post.

get_attachment_link()

Retrieves the permalink for an attachment.

get_children()

Retrieve all children of the post parent ID.

get_post_mime_type()

Retrieve the mime type of an attachment based on the ID.

is_local_attachment()

Check if the attachment URI is local one and is really an attachment.

the_attachment_link()

Display an attachment page link using an image or icon.

wp_attachment_is()

Verifies an attachment is of a given type.

wp_delete_attachment()

Trash or delete an attachment.

wp_get_attachment_link()

Retrieve an attachment page link using an image or icon, if possible.

wp_get_attachment_url()

Retrieve the URL for an attachment.

wp_insert_attachment()

Insert an attachment.

Thumbnails

add_image_size()

Register a new image (thumbnail) size.

delete_post_thumbnail()

Remove a post thumbnail.

get_intermediate_image_sizes()

Gets the available intermediate image sizes.

get_post_thumbnail_id()

Retrieve post thumbnail ID.

get_the_post_thumbnail()

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

get_the_post_thumbnail_caption()

Returns the post thumbnail caption.

get_the_post_thumbnail_url()

Return the post thumbnail URL.

has_image_size()

Check if an image size exists.

has_post_thumbnail()

Check if post has an image attached.

image_get_intermediate_size()

Retrieves the image's intermediate size (resized) path, width, and height.

remove_image_size()

Remove a new image size.

set_post_thumbnail()

Set a post thumbnail.

set_post_thumbnail_size()

Registers an image size for the post thumbnail.

the_post_thumbnail()

Display the post thumbnail.

the_post_thumbnail_caption()

Displays the post thumbnail caption.

the_post_thumbnail_url()

Display the post thumbnail URL.

wp_get_additional_image_sizes()

Retrieve additional image sizes.

wp_get_attachment_thumb_url()

Retrieve URL for an attachment thumbnail.

wp_get_image_editor()

Returns a WP_Image_Editor instance and loads file into it.

Rarely used

attachment_url_to_postid()

Tries to convert an attachment URL into a post ID.

get_allowed_mime_types()

Retrieve list of allowed mime types and file extensions.

wp_check_filetype()

Retrieve the file type from the file name.

wp_get_audio_extensions()

Returns a filtered list of WP-supported audio formats.

wp_get_ext_types()

Retrieves the list of common file extensions and their types.

wp_get_video_extensions()

Returns a filtered list of WP-supported video formats.

Gallery

get_post_galleries()

Retrieves galleries from the passed post's content.

get_post_galleries_images()

Retrieve the image srcs from galleries from a post's content, if present

get_post_gallery()

Check a specified post's content for gallery and, if present, return the first

get_post_gallery_images()

Checks a post's content for galleries and return the image srcs for the first found gallery

Images

image_downsize()

Scale an image to fit a particular size (such as 'thumb' or 'medium').

next_image_link()

Displays next image link that has the same post parent.

previous_image_link()

Displays previous image link that has the same post parent.

wp_attachment_is_image()

Checks if the attachment is an image.

wp_get_attachment_caption()

Retrieves the caption for an attachment.

wp_get_attachment_image()

Get an HTML img element representing an image attachment

wp_get_attachment_image_sizes()

Retrieves the value for an image attachment's 'sizes' attribute.

wp_get_attachment_image_src()

Retrieve an image to represent an attachment.

wp_get_attachment_image_srcset()

Retrieves the value for an image attachment's 'srcset' attribute.

wp_get_attachment_image_url()

Get the URL of an image attachment.

wp_get_image_mime()

Gets the real MIME type of an image file.

Upload/Download

media_handle_sideload()

Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload().

media_handle_upload()

Save a file submitted from a POST request and create an attachment post for it.

media_sideload_image()

Downloads an image from the specified URL and attaches it to a post.

wp_get_upload_dir()

Retrieves uploads directory information.

wp_handle_sideload()

Wrapper for _wp_handle_upload().

wp_handle_upload()

Wrapper for _wp_handle_upload().

wp_unique_filename()

Get a filename that is sanitized and unique for the given directory.

wp_upload_bits()

Create a file in the upload folder with given content.

wp_upload_dir()

Get an array containing the current upload directory's path and url.

Metadata (postmeta)

wp_generate_attachment_metadata()

Generate post thumbnail attachment meta data.

wp_get_attachment_metadata()

Retrieve attachment meta field for attachment ID.

wp_read_audio_metadata()

Retrieve metadata from a audio file's ID3 tags

wp_update_attachment_metadata()

Update metadata for an attachment.