AttachmentImages final class
Minn\Runtime\AttachmentImages · public/minn/src/Minn/Runtime/AttachmentImages.php · 422 lines
An attachment's image as WordPress's media functions make it: the registered sizes, a size fitted to a box, the file for a size (or an icon), the srcset and sizes pair, the loading attributes an image earns where it sits, the img element itself, and the site icon.
Public
| static | sizes(): array# | The registered sizes (_minn_image_sizes): the four from the options, then the ones add_image_size added. @return array<string, array<string, mixed>> | |||
| static | additionalSizes(): array# | The sizes plugins and themes added (wp_get_additional_image_sizes), kept where they read them: $_wp_additional_image_sizes. @return array<string, mixed> | |||
| static | constrain(mixed $width, mixed $height, mixed $maxWidth = 0, mixed $maxHeight = 0): mixed# | Dimensions fitted inside a box (wp_constrain_dimensions), through wp_constrain_dimensions when there is a box. @return array{0: int, 1: int} | |||
| static | matchesRatio(mixed $sourceWidth, mixed $sourceHeight, mixed $targetWidth, mixed $targetHeight): bool# | Whether two sizes share a ratio (wp_image_matches_ratio): the wider one, fitted into the other's box, comes within a pixel of it. | |||
| static | constrainForEditor(mixed $width, mixed $height, mixed $size = 'medium', mixed $context = NULL): mixed# | Dimensions fitted for the editor to a named or given size (image_constrain_size_for_editor), within editor_max_image_size. @return array{0: int, 1: int} | |||
| static | intermediate(mixed $postId, mixed $size = 'thumbnail'): mixed# | An attachment's file for a size (image_get_intermediate_size), as image_get_intermediate_size leaves it; false for none. | |||
| static | downsize(mixed $id, mixed $size = 'medium'): mixed# | An image attachment at a size (image_downsize): its address, width, height and whether that is a resized copy, unless image_downsize answers first; false for no image. | |||
| static | src(mixed $attachmentId, mixed $size = 'thumbnail', mixed $icon = false): mixed# | An attachment's image at a size, or its icon when asked (wp_get_attachment_image_src), as wp_get_attachment_image_src leaves it. | |||
| static | sizeFromMeta(mixed $sizeName, mixed $imageMeta): mixed# | A named size's dimensions from an image's metadata (_wp_get_image_size_from_meta): full for the original; false for one it lacks. | |||
| static | srcset(mixed $sizeArray, mixed $imageSrc, mixed $imageMeta, mixed $attachmentId = 0): mixed# | The srcset of an image's sizes with its ratio (wp_calculate_image_srcset), as wp_calculate_image_srcset leaves the sources; false for none. | |||
| static | sizesAttribute(mixed $size, mixed $imageSrc = NULL, mixed $imageMeta = NULL, mixed $attachmentId = 0): mixed# | The sizes attribute for an image's width (wp_calculate_image_sizes), as wp_calculate_image_sizes leaves it; false without a width. | |||
| static | startsWithAuto(mixed $sizes): bool# | Whether a sizes list starts with auto, alone or before a comma, in any case (wp_sizes_attribute_includes_valid_auto). | |||
| static | dimensionAttributes(mixed $width, mixed $height): string# | The width and height attributes for an image (image_hwstring), each when set. | |||
| static | lazyLoading(mixed $tagName, mixed $context): mixed# | Whether lazy loading is on for a tag in a context (wp_lazy_loading_enabled): images and iframes, as wp_lazy_loading_enabled leaves it. | |||
| static | loadingAttributes(mixed $tagName, mixed $attr, mixed $context): mixed# | The loading attributes an image or iframe earns (wp_get_loading_optimization_attributes), unless a plugin answers first: decoding async for an image; with both dimensions set, the caller's own priority and loading, else where it sits. | |||
| static | earnedPriority(string $tagName, array $attr): array# | Fetch priority high for an image large enough to deserve it, while no other image has taken it.
@return array<string, string> | |||
| static | imageAttributes(int $attachmentId, array $attr, string $src, int $width, int $height, string $context = 'wp_get_attachment_image'): array# | The loading attributes and the srcset and sizes pair an attachment's image carries unless the caller set them.
@return array<string, mixed> | |||
| static | image(mixed $attachmentId, mixed $size = 'thumbnail', mixed $icon = false, mixed $attr = ''): mixed# | An attachment's img element at a size (wp_get_attachment_image): its class, alt text, loading attributes and srcset, through wp_get_attachment_image_attributes and wp_get_attachment_image; empty for none. | |||
| static | siteIconUrl(mixed $size = 512, mixed $url = '', mixed $blogId = 0): mixed# | The site icon's address at a size (get_site_icon_url), the address given when the site has none; as get_site_icon_url leaves it. | |||
| static | hasSiteIcon(mixed $blogId = 0): bool# | Whether the site has an icon (has_site_icon). |
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | asked(string $tagName, array $attr, ?string $priority, array $optimization): ?array# | What a caller's own fetchpriority high or loading settles; null when it named neither. Only an image takes high priority, and an element that names a loading other than lazy is never made lazy.
@return array<string, mixed>|null | ||||||
| private | byPlace(string $tagName, array $attr, string $context, array $optimization): array# | Where an element sits settles the rest. One in a header context is in view: never lazy, one of the eager images. Inside a page's template, or its main loop, an image shares the engine's budget: three eager images, the first one large enough to deserve it high priority. Anything else waits, where lazy loading is on.
@return array<string, mixed> |
Nothing matches.