Recent

Media_Handlerclass

Media_Handler

Media Handler class.

Namespace: WebberZone\Contextual_Related_Posts\Frontend
Since: 3.5.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;
Type Name Description
string|array $args {

Returns: string — Image tag

get_image_html() static

Get an HTML img element.

Delegates to {@see wp_get_attachment_image()} when an attachment ID is available; otherwise builds the tag manually.

Line: 799

static public function get_image_html( $attachment_url, $attr = ..., $attachment_id = ..., $size = ... ): string;
Type Name Description
string $attachment_url Image URL.
array $attr Optional. Attributes for the image markup.
int $attachment_id Optional. Attachment ID. Default 0.
string|int[] $size Optional. 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: 960

static public function get_image_hwstring( $args = ... ): string;
Type Name Description
array $args Argument array.

Returns: string — Height-width string.

get_first_image() static

Get the first child image in the post.

Line: 994

static public function get_first_image( $postid, int $thumb_width, int $thumb_height ): string;
Type Name Description
int|\WP_Post $postid Post ID or WP_Post object.
int $thumb_width Thumb width.
int $thumb_height Thumb height.

Returns: string — Location of thumbnail.

get_cached_attachment_id() static

Get cached attachment ID from URL to prevent database exhaustion.

Line: 1048

static public function get_cached_attachment_id( $attachment_url = ... ): int;
Type Name Description
string $attachment_url Attachment 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: 1095

static public function get_base_image_url( $url ): string;
Type Name Description
string $url Image 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: 1106

static public function get_thumb_size( $size = ... ): array;
Type Name Description
string $size Image 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: 1138

static public function get_all_image_sizes( $size = ... ): array;
Type Name Description
string|int[] $size Image 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: 1169

static public function get_appropriate_image_size( $thumb_width, $thumb_height ): string|bool;
Type Name Description
int $thumb_width Thumbnail width.
int $thumb_height Thumbnail height.

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