Remove placeholder SVG, add dummy function
A colored background works too.
This commit is contained in:
parent
06853b9dd2
commit
68878a94fa
@ -741,12 +741,13 @@ if ( ! function_exists( 'fictioneer_get_placeholder_image' ) ) {
|
||||
|
||||
// Fallback
|
||||
if ( empty( $image_large ) || empty( $image_full ) ) {
|
||||
$svg = fictioneer_get_svg_rect( '#111', 400, 600 );
|
||||
$generated = fictioneer_generate_placeholder( $args );
|
||||
|
||||
$cache[ $cache_key ] = array(
|
||||
'thumbnail' => '<img src="' . $svg . '" class="' . $image_class . '" alt="' . $image_args['alt'] . '">',
|
||||
'thumbnail_url' => $svg,
|
||||
'thumbnail_full_url' => $svg,
|
||||
'thumbnail' => $generated ?
|
||||
'<img src="' . $generated . '" class="' . $image_class . '" alt="' . $image_args['alt'] . '">' : '',
|
||||
'thumbnail_url' => $generated,
|
||||
'thumbnail_full_url' => $generated,
|
||||
'generated' => true
|
||||
);
|
||||
|
||||
@ -814,7 +815,7 @@ if ( ! function_exists( 'fictioneer_output_small_card_thumbnail' ) ) {
|
||||
// Link (lightbox) with image tag
|
||||
echo "<a href='{$thumbnails['thumbnail_full_url']}' class='{$classes}' title='{$title}' {$lightbox_attribute}>{$thumbnails['thumbnail']}</a>";
|
||||
} elseif ( $vertical ) {
|
||||
// Placeholder image or generated SVG
|
||||
// Placeholder image
|
||||
$placeholder = fictioneer_get_placeholder_image();
|
||||
$url = $placeholder['thumbnail_full_url'];
|
||||
$classes .= ' _placeholder';
|
||||
|
@ -2871,29 +2871,21 @@ if ( ! function_exists( 'fictioneer_get_async_css_loading_pattern' ) ) {
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// CSS SVG RECT
|
||||
// GENERATE PLACEHOLDER
|
||||
// =============================================================================
|
||||
|
||||
if ( ! function_exists( 'fictioneer_get_svg_rect' ) ) {
|
||||
if ( ! function_exists( 'fictioneer_generate_placeholder' ) ) {
|
||||
/**
|
||||
* Returns generated SVG rectangle as base64 data URI
|
||||
* Dummy implementation (currently used a CSS background)
|
||||
*
|
||||
* @since 5.14.0
|
||||
*
|
||||
* @param string $color Optional. Color code of the rectangle. Default '#111'.
|
||||
* @param int $width Optional. Width of the rectangle. Default 200.
|
||||
* @param int $height Optional. Height of the rectangle. Default 300.
|
||||
* @param array|null $args Optional arguments to generate a placeholder.
|
||||
*
|
||||
* @return string SVG as data URI.
|
||||
* @return string The placeholder URL or data URI.
|
||||
*/
|
||||
|
||||
function fictioneer_get_svg_rect( $color = '#111', $width = 200, $height = 300 ) {
|
||||
// Build
|
||||
$svg = '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
$svg .= '<svg xmlns="http://www.w3.org/2000/svg" width="' . $width . '" height="' . $height . '" viewBox="0 0 ' . $width . ' ' . $height . '">';
|
||||
$svg .= '<rect width="100%" height="100%" fill="' . htmlspecialchars( $color ) . '" /></svg>';
|
||||
|
||||
// Return as data URI
|
||||
return 'data:image/svg+xml;base64,' . base64_encode( $svg );
|
||||
function fictioneer_generate_placeholder( $args = [] ) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user