Files
tylkofotografia/template-parts/header/headerImage.php
2026-01-15 12:23:11 +01:00

30 lines
1.5 KiB
PHP

<?php
/**
* Szablon obrazka nagłówka
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
global $wpdb;
$upload_dir = wp_upload_dir();
if (!wp_is_mobile() && has_header_image()) {
?><div class="content" id="banner">
<?php
if (function_exists('getResponsiveImage')) {
$data = get_object_vars(get_theme_mod('header_image_data'));
$attachment_id = is_array($data) && isset($data['attachment_id']) ? $data['attachment_id'] : false;
if($attachment_id && is_front_page () && is_home ()) {
$webp2x = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}responsive_images where `img_filetype` in ('webp') and `img_size` = '2x' and `img_post_id` = " . $attachment_id);
$webp1x = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}responsive_images where `img_filetype` in ('webp') and `img_size` = '1x' and `img_post_id` = " . $attachment_id);
//echo getResponsiveImage( ['id' => $attachment_id, 'align' => '', 'caption' => ''] );
?><div style='background-image: -webkit-image-set( url("<?php echo $upload_dir["baseurl"] . $webp1x->img_location; ?>?x=5") 1x, url("<?php echo $upload_dir["baseurl"] . $webp2x->img_location; ?>?x=5") 2x); background-repeat: no-repeat; background-position: top; background-size: cover; height:353px; margin-bottom: 20px;'>
</div>
<?php } } else {
?><img src="<?php echo get_header_image() ; ?>" alt="<?php echo esc_attr( get_bloginfo( 'title' ) ); ?>" />
<?php } ?>
</div>
<?php }