HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/MDalebout3/prdct.nl/wwwroot/wp-content/themes/theme/blocks/block-central-image.php
<?php
/**
     * Sublogo Block Template.
     *
     * @param   array $block The block settings and attributes.
     * @param   string $content The block inner HTML (empty).
     * @param   bool $is_preview True during AJAX preview.
     * @param   (int|string) $post_id The post ID this block is saved to.
     */

    // Create id attribute allowing for custom "anchor" value.
    $id = 'central-image-' . $block['id'];
    if( !empty($block['anchor']) ) {
        $id = $block['anchor'];
    }

    // Create class attribute allowing for custom "className" and "align" values.
    $className = 'central-image';
    if( !empty($block['className']) ) {
        $className .= ' ' . $block['className'];
    }
    if( !empty($block['align']) ) {
        $className .= ' align' . $block['align'];
    }

    // Load values and assign defaults.
    if (!wp_is_mobile()) {
    //$central_image = get_field('central_image') ?: wp_get_attachment_image_url( 24,'full');
        $js = get_field('js');
        $html = get_field('html');
        $image = get_field('image');
        $class = 'animation-desktop';
    } else {
        $js = get_field('js_mobile');
        $html = get_field('html_mobile');
        $image = get_field('image_mobile');
        $class = 'animation-mobile';
    }
?>
    <section class="block-central-image <?php echo $class; ?>">
        <div class="section-inner">
<!--            <img src="--><?php //echo $central_image; ?><!--">-->
            <div class="animation">
            <?php
            $htmlfile = new DOMDocument;
            libxml_use_internal_errors(true);
            $htmlfile->loadHTMLFile($html['url']);
            foreach ($htmlfile->getElementsByTagName("script") as $element)
            {
                $src = $element->getAttribute('src');

                if (strpos($src,'https',0) !== false) {
                    //var_dump($src); ?>
                    <script src="<?php echo $element->getAttribute('src'); ?>"></script>
                    <script src="<?php  echo $js['url']; ?>"></script>
                <?php } else {
                if ($src == "") { ?>
                    <script>
                    <?php
                    $image_path = str_replace(get_site_url(), '',$image['url']);
                    echo str_replace("var lib=comp.getLibrary();","var lib=comp.getLibrary(); lib.properties.manifest[0].src = '$image_path';/*console.log(lib.properties.manifest[0].src);*/", $element->nodeValue); ?>
                    jQuery(document).ready(function($) {
                        $(window).on('load scroll', function() {
                            if (!$(".block-central-image").hasClass('loaded')) {
                                let scrollBool = isScrolledIntoView($(".block-central-image"));
                                if (scrollBool===true) {
                                    $(".block-central-image").addClass('loaded');
                                    init();
                                }
                            }
                        })

                    })

                    </script>
                <?php }
                }
            }
            $body = $htmlfile->getElementById('animation_container');

            echo $htmlfile->saveHTML($body);
            libxml_clear_errors(); ?>
            </div>
        </div>

    </section>