generated from bisco/codex-bootstrap
fix: render customizer images through wordpress media
This commit is contained in:
@@ -45,6 +45,30 @@ function azionelab_asset( string $filename ): string {
|
||||
return get_theme_file_uri( 'assets/images/' . $filename );
|
||||
}
|
||||
|
||||
function azionelab_image( string $url, string $alt, array $attributes = array() ): string {
|
||||
$attributes = array_merge(
|
||||
array(
|
||||
'alt' => $alt,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
|
||||
$attachment_id = attachment_url_to_postid( $url );
|
||||
if ( $attachment_id > 0 ) {
|
||||
return wp_get_attachment_image( $attachment_id, 'large', false, $attributes ) ?: '';
|
||||
}
|
||||
|
||||
$html_attributes = '';
|
||||
foreach ( $attributes as $name => $value ) {
|
||||
if ( '' === (string) $value ) {
|
||||
continue;
|
||||
}
|
||||
$html_attributes .= sprintf( ' %s="%s"', esc_attr( $name ), esc_attr( (string) $value ) );
|
||||
}
|
||||
|
||||
return sprintf( '<img src="%s"%s>', esc_url( $url ), $html_attributes );
|
||||
}
|
||||
|
||||
function azionelab_phone_href( string $number ): string {
|
||||
return preg_replace( '/[^0-9+]/', '', $number ) ?: '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user