403Webshell
Server IP : 130.225.57.55  /  Your IP : 216.73.216.60
Web Server : Apache
System : Linux wp-vhost07 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /srv/www/reco2st.eu/https/wp-content/themes/erc04961/library/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /srv/www/reco2st.eu/https/wp-content/themes/erc04961/library/helpers/class-image.php
<?php
/**
 * WordPress Responsive Images
 * Implementation
 *
 * @author Max G J Panas <http://maxpanas.com>
 */

/**
 * Class MOZ_Image
 *
 */
class MOZ_Image {

    private static $wp_footer_hook_engaged = FALSE;

    /**
     * Maybe "lazify" the attributes
     * of an image depending on
     * whether it should
     * be lazy-loaded
     *
     * @param array $flags
     * @param array $attrs
     * @param bool|null $add_class
     * @param bool|null $add_src
     *
     * @return array
     */
    public static function maybe_lazify( $flags, $attrs, $add_class = true, $add_src = true ) {
        if ( !self::is_lazy( $flags ) ) {
            return $attrs;
        }

        $lazifiables = array( 'src', 'srcset', 'sizes' );
        foreach ( $lazifiables as $lazifiable ) {
            if ( isset( $attrs[ $lazifiable ] ) ) {
                $attrs[ "data-$lazifiable" ] = $attrs[ $lazifiable ];
                unset( $attrs[ $lazifiable ] );
            }
        }

        if ( $add_class && self::should_add_lazy_class( $flags ) ) {
            $attrs[ 'class' ] = isset( $attrs[ 'class' ] ) ? "{$attrs[ 'class' ]} lazyload" : 'lazyload';
        }

        if ( $add_src ) {
            $attrs[ 'src' ] = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
        }

        return $attrs;
    }

    /**
     * Get an image's alt
     * attribute content
     *
     * @param $image
     *
     * @return string
     */
    public static function get_img_alt( $image ) {
        return trim( strip_tags( get_post_meta( $image, '_wp_attachment_image_alt', true ) ) );
    }

    /**
     * Print an image's alt
     * attribute content
     *
     * @param $image
     */
    public static function img_alt( $image ) {
        echo self::get_img_alt( $image );
    }

    /**
     * Get an image's src
     * attribute for the
     * specified size
     *
     * @param        $image
     * @param string $size
     *
     * @return bool
     */
    public static function get_src( $image, $size = 'full' ) {
        if ( $src = wp_get_attachment_image_src( $image, $size, false ) ) {
            return $src[ 0 ];
        }

        return false;
    }


/**
     * Get a scaled image's local path
     * for the specified size
     *
     * @param        $image
     * @param string $size
     */
    public static function scaled_image_path($attachment_id, $size = 'full') {
        $file = get_attached_file($attachment_id, true);
        if (empty($size) || $size === 'full') {
            // for the original size get_attached_file is fine
            return realpath($file);
        }
        if (! wp_attachment_is_image($attachment_id) ) {
            return false; // the id is not referring to a media
        }
        $info = image_get_intermediate_size($attachment_id, $size);
        if (!is_array($info) || ! isset($info['file'])) {
            return false; // probably a bad size argument
        }
    
        return realpath(str_replace(wp_basename($file), $info['file'], $file));
    }

    /**
     * Print an image's src
     * attribute for the
     * specified size
     *
     * @param        $image
     * @param string $size
     */
    public static function src( $image, $size = 'full' ) {
        echo self::get_src( $image, $size );
    }

    /**
     * Get the markup for a
     * responsive background
     * image
     *
     * @param int $image
     * @param string $baseSize
     * @param array $sizes
     * @param array|null $attrs
     * @param array|null $flags
     *
     * @return bool|string
     */
    public static function get_background( $image, $baseSize = 'full', $sizes = array(), $attrs = array(), $flags = array() ) {
        if ( !wp_attachment_is_image( $image ) ) {
            return false;
        }

        $writeImmediateCssCode = (isset( $flags[ 'immediate_css' ] ) && $flags[ 'immediate_css' ] === true);

        $bgel_attrs = array_merge( array(
            'class' => '',
            'role' => 'img',
            'alt' => self::get_img_alt( $image )
                ), ( array ) $attrs );

        $alt = $bgel_attrs[ 'alt' ];
        unset( $bgel_attrs[ 'alt' ] );

        $content = MOZ_Html::get_element( 'span', array( 'class' => 'visuallyhidden' ), $alt );

        $bgel_attrs[ 'class' ] .= ' moz-background-picture';

        if ( self::is_lazy( $flags ) ) {
            // lazy loaded background image
            if ( self::should_add_lazy_class( $flags ) ) {
                $bgel_attrs[ 'class' ] .= ' lazyload';
            }

            $bgset = array( self::get_src( $image, $baseSize ) );
            foreach ( $sizes as $size => $query ) {
                $src = self::get_src( $image, $size );
                $bgset[] = "$src [$query]";
            }
            $bgel_attrs[ 'data-sizes' ] = 'auto';
            $bgel_attrs[ 'data-bgset' ] = implode( ' | ', array_reverse( $bgset ) );
        } else {
            // not lazy-loaded background image
            $unique = uniqid( 'moz-background-picture--' );
            $bgel_attrs[ 'class' ] .= " $unique";
            ?>
            <?php if ( !$writeImmediateCssCode ): ?>
                <script type="text/template" class="css-code-container">
                <?php endif; ?>
                <style type="text/css">
                    <?php $imageUrl = self::get_src( $image, $baseSize ); ?>
                    <?php if (self::attachment_webp_version_exists($image, $baseSize)): ?>
                        .webp .<?php echo $unique; ?> { background-image: url('<?php echo self::get_webp_image_url($imageUrl); ?>'); }                        
                        .no-webp .<?php echo $unique; ?> { background-image: url('<?php echo $imageUrl; ?>'); }                     
                    <?php else: ?>
                        .<?php echo $unique; ?> { background-image: url('<?php echo $imageUrl; ?>'); }
                    <?php endif; ?>
                    <?php foreach ( $sizes as $size => $query ) : ?>
                        <?php $imageUrl = self::get_src( $image, $size ); ?>
                        @media all and <?php echo esc_html( $query ); ?> {     
                        <?php if (self::attachment_webp_version_exists($image, $size)): ?>
                            .webp .<?php echo $unique; ?> { background-image: url('<?php echo self::get_webp_image_url($imageUrl); ?>'); }                        
                            .no-webp .<?php echo $unique; ?> { background-image: url('<?php echo $imageUrl; ?>'); }                     
                        <?php else: ?>
                            .<?php echo $unique; ?> { background-image: url('<?php echo $imageUrl; ?>'); }
                        <?php endif; ?>
                        }
                    <?php endforeach; ?>
                </style>
                <?php if ( !$writeImmediateCssCode ): ?>
                </script>
            <?php endif; ?>
            <?php
            if ( static::$wp_footer_hook_engaged === FALSE ) {
                add_action( 'wp_footer', 'Moz_Image::output_image_background_styles' );
                static::$wp_footer_hook_engaged = TRUE;
            }
        }

        return MOZ_Html::get_element( 'span', $bgel_attrs, $content );
    }

    public static function output_image_background_styles() {
        ?>
        <script type="text/javascript">
            ( function () {
                var head = document.getElementsByTagName( 'head' )[0];
                var styleTemplates = document.querySelectorAll( 'script.css-code-container' );
                for ( i = 0; i < styleTemplates.length; i++ ) {
                    try {
                        head.insertAdjacentHTML( 'beforeend', styleTemplates[i].innerHTML );
                    } catch ( ex ) {
                        console.log( ex );
                    }
                }
            } )();
        </script>
        <?php
    }

    /**
     * Print the markup for a
     * responsive background
     * image
     *
     * @param int $image
     * @param string $baseSize
     * @param array $sizes
     * @param array|null $attrs
     * @param array|null $flags
     */
    public static function background( $image, $baseSize = 'full', $sizes = array(), $attrs = array(), $flags = array() ) {
        echo self::get_background( $image, $baseSize, $sizes, $attrs, $flags );
    }

    /**
     * Get the markup for a
     * picture element
     *
     * @param int $image
     * @param string $baseSize
     * @param array $sizes
     * @param array|null $attrs
     * @param array|null $flags
     *
     * @return bool|string
     */
    public static function get_picture( $image, $baseSize, $sizes, $attrs = array(), $flags = array() ) {
        if ( !wp_attachment_is_image( $image ) ) {
            return false;
        }

        $content = array();

        // required for IE9 support...
        $content[] = '<!--[if IE 9]><video style="display: none;"><![endif]-->';

        foreach ( array_reverse( $sizes ) as $size => $query ) {
            $source_attrs = self::maybe_lazify( $flags, array(
                        'srcset' => esc_attr( self::get_src( $image, $size ) ),
                        'media' => esc_attr( $query ),
                        'type' => esc_attr( get_post_mime_type( $image ) )
                            ), false, false );

            $content[] = MOZ_Html::get_sc_element( 'source', $source_attrs );
        }

        $content[] = '<!--[if IE 9]></video><![endif]-->';

        $img_attrs = self::maybe_lazify( $flags, array_merge( array(
                    'srcset' => esc_attr( self::get_src( $image, $baseSize ) ),
                    'src' => esc_attr( self::get_src( $image, $baseSize ) ),
                    'alt' => self::get_img_alt( $image )
                                ), ( array ) $attrs ) );

        $content[] = MOZ_Html::get_sc_element( 'img', $img_attrs );

        return MOZ_Html::get_element( 'picture', null, implode( '', $content ) );
    }



    /**
     * Print the markup for a
     * picture element
     *
     * @param int $image
     * @param string $baseSize
     * @param array $sizes
     * @param array|null $attrs
     * @param array|null $flags
     */
    public static function picture( $image, $baseSize = 'full', $sizes = array(), $attrs = array(), $flags = array() ) {
        echo self::get_picture( $image, $baseSize, $sizes, $attrs, $flags );
    }

    public static function attachment_webp_version_exists($image, $size = 'full') {
        $imagePath = self::scaled_image_path($image, $size);
        if (!empty($imagePath)) {
            $webImagePath = self::get_webp_image_url($imagePath);      
            return file_exists($webImagePath);
        }
        return false;
    }

	public static function get_webp_image_url($url) {
        $parts = explode('.', $url);
        array_pop($parts);
        array_push($parts, 'webp');
        return implode('.', $parts);
    }

    /**
     * Get the markup for an image
     * using srcset and sizes
     *
     * @param int $image
     * @param array $sources
     * @param array $sizes
     * @param array|null $attrs
     * @param array|null $flags
     *
     * @returns string
     */

	public static function get_lazy( $image, $baseSize = 'full', $sizes = array(), $attrs = array()) {
		if ( !wp_attachment_is_image( $image ) ) {
			return false;
        }
        
        if (empty($baseSize)) {
            $baseSize = 'full';
        }

        if (empty($sizes)) {
            $sizes = [ 
                $baseSize => '16384w'
             ];
        }

		$img_attrs = array();
		$content = array();
        $datasrc = [];
		// required for IE9 support...
		$content[] = '<!--[if IE 9]><video style="display: none;"><![endif]-->';
		if($sizes) {
		    foreach ($sizes as $size => $width){
		        $imageUrl = self::get_src( $image, $size );
		        if ($imageUrl !== FALSE) {                    
			        $datasrc[] = esc_attr( $imageUrl ) . ' ' . $width;
                    if (self::attachment_webp_version_exists($image, $size)) {
                        $datasrc[] = esc_attr(self::get_webp_image_url($imageUrl)) . ' ' . $width;
                    }
		        }
            }
        }
		$img_attrs['data-srcset'] = implode(', ', $datasrc);
		$img_attrs['src'] = esc_attr( self::get_src( $image, $baseSize ) );
		$img_attrs['alt'] = self::get_img_alt( $image );
		$img_attrs['srcset'] = "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
		$img_attrs['class'] = "responsively-lazy";

		$content[] = '<!--[if IE 9]></video><![endif]-->';

		$content[] = MOZ_Html::get_sc_element( 'img', $img_attrs );

		return MOZ_Html::get_element( 'picture', null, implode( '', $content ) );
	}


	public static function lazy( $image, $baseSize = 'full', $sizes = array(), $attrs = array() ) {
		echo self::get_lazy( $image, $baseSize, $sizes, $attrs);
	}


    public static function get_image( $image, $sources, $sizes = array(), $attrs = array(), $flags = array() ) {
        if ( !wp_attachment_is_image( $image ) ) {
            return false;
        }

        $srcset = array();
        foreach ( $sources as $size ) {
            if ( $src = wp_get_attachment_image_src( $image, $size, false ) ) {
                $srcset[] = "{$src[ 0 ]} {$src[ 1 ]}w {$src[ 2 ]}h";
            }
        }

        if ( empty( $srcset ) ) {
            return false;
        }

        $img_attrs = self::maybe_lazify( $flags, array_merge( array(
                    'srcset' => implode( ', ', $srcset ),
                    'sizes' => implode( ', ', $sizes ),
                    'alt' => self::get_img_alt( $image )
                                ), ( array ) $attrs ) );

        return MOZ_Html::get_sc_element( 'img', $img_attrs );
    }

    /**
     * Print the markup for an image
     * using srcset and sizes
     *
     * @param int $image
     * @param array $sources
     * @param array $sizes
     * @param array|null $attrs
     * @param array|null $flags
     */
    public static function image( $image, $sources, $sizes, $attrs = array(), $flags = array() ) {
        echo self::get_image( $image, $sources, $sizes, $attrs, $flags );
    }

    /**
     * Determine whether an
     * image should be
     * lazy-loaded
     *
     * default: false
     *
     * @param array $flags
     *
     * @return bool
     */
    protected static function is_lazy( $flags ) {
        return isset( $flags[ 'lazy' ] ) && !!$flags[ 'lazy' ];
    }

    /**
     * Determine whether a
     * lazy image should have
     * the lazy class from the
     * start
     *
     * default: true
     *
     * @param array $flags
     *
     * @return bool
     */
    protected static function should_add_lazy_class( $flags ) {
        return isset( $flags[ 'lazy_class' ] ) ? !!$flags[ 'lazy_class' ] : true;
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit