diff --git a/gdpr-content-blocker/assets/frontend.js b/gdpr-content-blocker/assets/frontend.js index 9d0a349..e7a6185 100644 --- a/gdpr-content-blocker/assets/frontend.js +++ b/gdpr-content-blocker/assets/frontend.js @@ -126,6 +126,16 @@ if ( blockerEl.dataset.width ) iframe.width = blockerEl.dataset.width; if ( blockerEl.dataset.height ) iframe.height = blockerEl.dataset.height; + // Responsive aspect (Elementor video widgets we build ourselves): full + // width at the given ratio, so it loads at its original proportions even + // without a definite parent height. + if ( blockerEl.dataset.cbAspect ) { + iframe.style.width = '100%'; + iframe.style.height = 'auto'; + iframe.style.aspectRatio = blockerEl.dataset.cbAspect; + } + iframe.style.border = '0'; + iframe.setAttribute( 'loading', 'lazy' ); iframe.setAttribute( 'allowfullscreen', '' ); iframe.setAttribute( 'referrerpolicy', 'no-referrer-when-downgrade' ); @@ -409,15 +419,19 @@ // Neutralise Elementor so it won't build the player / load the overlay. widget.removeAttribute( 'data-settings' ); - const placeholder = buildPlaceholder( svc, embed, {} ); - // These widgets are built entirely by JS (no server iframe we could - // catch). Rather than guess the embed size, reload on consent so - // Elementor renders the player natively at its ORIGINAL size. Drop the - // "load once" option (it can't apply here). - placeholder.setAttribute( 'data-cb-reload', '1' ); - const remember = placeholder.querySelector( '.cb-blocker__remember' ); - if ( remember ) remember.remove(); + // With an embed URL we build the iframe ourselves on consent (reliable, + // independent of Elementor/iframe_api). The iframe gets a responsive + // 16:9 aspect so it loads full-width at its original proportions. + // Without a URL we fall back to reloading so Elementor renders it. + const placeholder = buildPlaceholder( svc, embed, {} ); + if ( embed ) { + placeholder.dataset.cbAspect = '16 / 9'; + } else { + placeholder.setAttribute( 'data-cb-reload', '1' ); + const remember = placeholder.querySelector( '.cb-blocker__remember' ); + if ( remember ) remember.remove(); + } container.innerHTML = ''; container.appendChild( placeholder ); diff --git a/gdpr-content-blocker/gdpr-content-blocker.php b/gdpr-content-blocker/gdpr-content-blocker.php index fec32ed..8561d9b 100644 --- a/gdpr-content-blocker/gdpr-content-blocker.php +++ b/gdpr-content-blocker/gdpr-content-blocker.php @@ -3,7 +3,7 @@ * Plugin Name: GDPR Content Blocker * Plugin URI: https://lucas-orth.de * Description: DSGVO-konformer Consent-Blocker für externe iframes. Lädt Drittinhalte erst nach aktiver Einwilligung. - * Version: 1.4.5 + * Version: 1.4.6 * Author: Lucas Orth * Author URI: https://lucas-orth.de * Text Domain: gdpr-content-blocker @@ -15,7 +15,7 @@ defined( 'ABSPATH' ) || exit; -define( 'CB_VERSION', '1.4.5' ); +define( 'CB_VERSION', '1.4.6' ); define( 'CB_FILE', __FILE__ ); define( 'CB_DIR', plugin_dir_path( __FILE__ ) ); define( 'CB_URL', plugin_dir_url( __FILE__ ) );