Recent

Media_Handler class

Media_Handler

Media Handler class.

Namespace: WebberZone\Knowledge_Base\Frontend
Since: 2.3.0
Source: includes/frontend/class-media-handler.php line 19

Methods

add_image_sizes() static

Add custom image size of thumbnail. Filters init.

Line: 59

static public function add_image_sizes(  );

get_the_post_thumbnail() static

Function to get the post thumbnail.

Line: 98

static public function get_the_post_thumbnail( $args = ... ): string;
TypeNameDescription
string|array$args{

Returns: string — Image tag

get_image_html() static

Get an HTML img element.

When an attachment ID is available the function delegates to {@see wp_get_attachment_image()} so that srcset, sizes and all core image optimisations are applied automatically.

When only a URL is available (external images, meta-key URLs, etc.) the function builds the <img> tag manually using the configured thumbnail dimensions and attributes.

Line: 807

static public function get_image_html( $attachment_url, $attr = ..., $attachment_id = ..., $size = ... ): string;
TypeNameDescription
string$attachment_urlImage URL.
array$attrOptional. Attributes for the image markup.
int$attachment_idOptional. Attachment ID. Default 0.
string&#124;int[]$sizeOptional. Registered image size name or

Returns: string — HTML img element or empty string on failure.

get_image_hwstring() static

Retrieve width and height attributes using given width and height values.

Line: 968

static public function get_image_hwstring( $args = ... ): string;
TypeNameDescription
array$argsArgument array.

Returns: string — Height-width string.

get_first_image() static

Get the first child image in the post.

Line: 1002

static public function get_first_image( $postid, int $thumb_width, int $thumb_height ): string;
TypeNameDescription
int&#124;\WP_Post$postidPost ID or WP_Post object.
int$thumb_widthThumb width.
int$thumb_heightThumb height.

Returns: string — Location of thumbnail.

get_cached_attachment_id() static

Get cached attachment ID from URL to prevent database exhaustion.

Line: 1056

static public function get_cached_attachment_id( $attachment_url = ... ): int;
TypeNameDescription
string$attachment_urlAttachment URL.

Returns: int — Attachment ID.

get_base_image_url() static

Get the base image URL by stripping WordPress size suffixes.

Converts URLs like image-150x150.jpg or image-1024x768.jpg to image.jpg

Line: 1103

static public function get_base_image_url( $url ): string;
TypeNameDescription
string$urlImage URL potentially with size suffix.

Returns: string — Base image URL without size suffix.

get_thumb_size() static

Function to get the correct height and width of the thumbnail.

Line: 1114

static public function get_thumb_size( $size = ... ): array;
TypeNameDescription
string$sizeImage size.

Returns: array — Width and height. If no width and height is found, then 150 is returned for each.

get_all_image_sizes() static

Get all image sizes.

Line: 1146

static public function get_all_image_sizes( $size = ... ): array;
TypeNameDescription
string&#124;int[]$sizeImage size.

Returns: array — If a single size is specified, then the array with width, height and crop status

get_appropriate_image_size() static

Get the most appropriate image size based on the given thumbnail width and height.

Line: 1177

static public function get_appropriate_image_size( $thumb_width, $thumb_height ): string|bool;
TypeNameDescription
int$thumb_widthThumbnail width.
int$thumb_heightThumbnail height.

Returns: string|bool — Image size name if found, false otherwise.