images.php
File: inc/images.php Theme: Shared Media Functions
Unified Media Architecture. Handles native image blocks, cover toggles, media-text toggles, site logo fallbacks, lightboxes, and legacy post loops.
Table of Contents
Constants
- DEFAULT_FEATURED_IMAGE : string = 'assets/images/pages/home-hero.webp'
- Default fallback featured IMAGE asset PATH.
- DEFAULT_SITE_LOGO : string = 'assets/images/logo/site-logo.webp'
- Default fallback site LOGO asset PATH.
- DEFAULT_SITE_LOGO_HEIGHT : int = 56
- Default fallback site LOGO pixel HEIGHT.
- DEFAULT_SITE_LOGO_WIDTH : int = 56
- Default fallback site LOGO pixel WIDTH.
- FORCE_DEFAULT_IMAGE : bool = false
- Flag to force default fallback IMAGE rendering during testing.
- FORCE_DEFAULT_SITE_LOGO : bool = false
- Flag to force default site LOGO rendering during testing.
Functions
- get_featured_image_fallback_data() : array{url: string, alt: string}
- 1A. THE FEATURED IMAGE ENGINE CORE Dynamically scans Lumina's asset directory for fallback featured images.
- get_default_site_logo_url() : string
- 1B. THE SITE LOGO ENGINE CORE Resolves default site logo from theme settings with fallback to DEFAULT_SITE_LOGO.
- get_default_site_logo_dimensions() : array{width: int, height: int}
- 1C. LOGO DIMENSIONS RESOLVER Resolves intrinsic or configured pixel dimensions for the fallback site logo.
- filter_cover_block_fallback() : string
- 2A. THE COVER TOGGLE INTERCEPT Intercepts Core Cover block rendering to inject fallback featured images.
- filter_media_text_block_fallback() : string
- 2B. THE MEDIA & TEXT TOGGLE INTERCEPT Intercepts Core Media & Text block rendering to inject fallback featured images.
- filter_site_logo_block_fallback() : string
- 2C. THE SITE LOGO BLOCK INTERCEPT Intercepts Core Site Logo block rendering to supply fallback logo markup.
- filter_get_custom_logo_fallback() : string
- 2D. THE LEGACY CUSTOM LOGO INTERCEPT Intercepts legacy get_custom_logo HTML output to supply fallback site logo.
- get_registered_image_size_dimensions() : array{width: int, height: int}
- Helper function to resolve pixel dimensions for standard or custom image sizes.
- filter_legacy_post_thumbnail_html() : string
- 3. THE POST THUMBNAIL / FEATURED IMAGE INTERCEPT Intercepts post_thumbnail_html to output fallback featured images for posts missing thumbnails.
- has_post_thumbnail_fallback() : bool
- 4. FORCE TRUE FOR WRAPPERS CONSISTENCY Forces has_post_thumbnail to return true so theme wrappers always render fallback markup.
Constants
DEFAULT_FEATURED_IMAGE
Default fallback featured IMAGE asset PATH.
public
string
DEFAULT_FEATURED_IMAGE
= 'assets/images/pages/home-hero.webp'
DEFAULT_SITE_LOGO
Default fallback site LOGO asset PATH.
public
string
DEFAULT_SITE_LOGO
= 'assets/images/logo/site-logo.webp'
DEFAULT_SITE_LOGO_HEIGHT
Default fallback site LOGO pixel HEIGHT.
public
int
DEFAULT_SITE_LOGO_HEIGHT
= 56
DEFAULT_SITE_LOGO_WIDTH
Default fallback site LOGO pixel WIDTH.
public
int
DEFAULT_SITE_LOGO_WIDTH
= 56
FORCE_DEFAULT_IMAGE
Flag to force default fallback IMAGE rendering during testing.
public
bool
FORCE_DEFAULT_IMAGE
= false
FORCE_DEFAULT_SITE_LOGO
Flag to force default site LOGO rendering during testing.
public
bool
FORCE_DEFAULT_SITE_LOGO
= false
Functions
get_featured_image_fallback_data()
1A. THE FEATURED IMAGE ENGINE CORE Dynamically scans Lumina's asset directory for fallback featured images.
get_featured_image_fallback_data([int|null $post_id = null ]) : array{url: string, alt: string}
Parameters
- $post_id : int|null = null
-
Optional post ID to calculate hashed image selections.
Return values
array{url: string, alt: string} —Fallback image URL and alt text array.
get_default_site_logo_url()
1B. THE SITE LOGO ENGINE CORE Resolves default site logo from theme settings with fallback to DEFAULT_SITE_LOGO.
get_default_site_logo_url() : string
Return values
string —Filtered logo image URL.
get_default_site_logo_dimensions()
1C. LOGO DIMENSIONS RESOLVER Resolves intrinsic or configured pixel dimensions for the fallback site logo.
get_default_site_logo_dimensions([int $target_width = 0 ]) : array{width: int, height: int}
Parameters
- $target_width : int = 0
-
Requested target pixel width.
Return values
array{width: int, height: int} —Dimension array containing width and height.
filter_cover_block_fallback()
2A. THE COVER TOGGLE INTERCEPT Intercepts Core Cover block rendering to inject fallback featured images.
filter_cover_block_fallback(string $block_content, array<string, mixed> $block) : string
Parameters
- $block_content : string
-
Rendered HTML output of the Cover block.
- $block : array<string, mixed>
-
Block configuration and attributes array.
Return values
string —Filtered Cover block HTML output.
filter_media_text_block_fallback()
2B. THE MEDIA & TEXT TOGGLE INTERCEPT Intercepts Core Media & Text block rendering to inject fallback featured images.
filter_media_text_block_fallback(string $block_content, array<string, mixed> $block) : string
Parameters
- $block_content : string
-
Rendered HTML output of the Media & Text block.
- $block : array<string, mixed>
-
Block configuration and attributes array.
Return values
string —Filtered Media & Text block HTML output.
filter_site_logo_block_fallback()
2C. THE SITE LOGO BLOCK INTERCEPT Intercepts Core Site Logo block rendering to supply fallback logo markup.
filter_site_logo_block_fallback(string $block_content, array<string, mixed> $block) : string
Parameters
- $block_content : string
-
Rendered HTML output of the Site Logo block.
- $block : array<string, mixed>
-
Block configuration and attributes array.
Return values
string —Filtered Site Logo block HTML output.
filter_get_custom_logo_fallback()
2D. THE LEGACY CUSTOM LOGO INTERCEPT Intercepts legacy get_custom_logo HTML output to supply fallback site logo.
filter_get_custom_logo_fallback(string $html[, int|null $blog_id = null ]) : string
Parameters
- $html : string
-
Existing custom logo HTML string.
- $blog_id : int|null = null
-
Optional blog ID context.
Return values
string —Filtered logo HTML string.
get_registered_image_size_dimensions()
Helper function to resolve pixel dimensions for standard or custom image sizes.
get_registered_image_size_dimensions(string|array<string|int, int> $size) : array{width: int, height: int}
Parameters
- $size : string|array<string|int, int>
-
Registered image size slug string or array of dimensions.
Return values
array{width: int, height: int} —Resolved width and height dimension array.
filter_legacy_post_thumbnail_html()
3. THE POST THUMBNAIL / FEATURED IMAGE INTERCEPT Intercepts post_thumbnail_html to output fallback featured images for posts missing thumbnails.
filter_legacy_post_thumbnail_html(string $html, int $pid, int $post_thumbnail_id, string|array<string|int, int> $size, array<string, mixed> $attr) : string
Parameters
- $html : string
-
Existing post thumbnail HTML output.
- $pid : int
-
Post ID context.
- $post_thumbnail_id : int
-
Attachment ID of the thumbnail.
- $size : string|array<string|int, int>
-
Requested image size slug or array.
- $attr : array<string, mixed>
-
Attributes array for the img tag.
Return values
string —Filtered post thumbnail HTML markup.
has_post_thumbnail_fallback()
4. FORCE TRUE FOR WRAPPERS CONSISTENCY Forces has_post_thumbnail to return true so theme wrappers always render fallback markup.
has_post_thumbnail_fallback(bool $has_thumbnail, WP_Post $post, int $thumbnail_id) : bool
Parameters
- $has_thumbnail : bool
-
Existing has_thumbnail check result.
- $post : WP_Post
-
Post object being evaluated.
- $thumbnail_id : int
-
Thumbnail attachment ID.
Return values
bool —Always true to enable fallback rendering.