]+?)src=[\'"]?([^\'"\s>]+)[\'"]?([^>]*)>#', sprintf( '
', $placeholder_image ), $content );
return $content;
}
/**
* Read and return unveil.js
* @link https://tommcfarlin.com/reading-files-with-php/
* @param file $filename The file for lazyloading
* @return string [description]
*/
static function italystrap_read_file( $filename ) {
// Check to see if the file exists at the specified path
if ( ! file_exists( $filename ) )
throw new Exception( "The file doesn't exist." );
// Open the file for reading
$file_resource = fopen( $filename, 'r' );
/* Read the entire contents of the file which is indicated by
* the filesize argument
*/
$content = fread( $file_resource, filesize( $filename ) );
fclose( $file_resource );
/**
* Add script for img opacity
* @var string Js Code
*/
// $output = 'jQuery(document).ready(function($){$("img").unveil(200, function(){$("img").load(function(){this.style.opacity = 1;});$(this).parent("img").css( "opacity","1");});});';
//Da testare
// $output = 'jQuery(document).ready(function($){$("img").unveil(200, function(){$(this).load(function(){$(this).css( "opacity","1");});});});';
$output = 'jQuery(document).ready(function($){$("img").unveil(200, function(){$("img").load(function(){this.style.opacity = 1;});});});';
$content .= $content . $output;
return $content;
}
/**
* Add css to opacize img first are append to src
* @return string Add opacity and transition to img
*/
static function custom_css(){
$custom_css = 'img{opacity:0;transition:opacity .3s ease-in;}';
// return $custom_css;
return null;
}
}
/**
* Return img tag lazyloaded
* @param string $content Text content to be processed
* @return string Text content processed
*/
function italystrap_get_apply_lazyload( $content ) {
_deprecated_function( __FUNCTION__, '2.0', 'ItalyStrap\\\Core\\\get_apply_lazyload' );
return ItalyStrapLazyload::add_image_placeholders( $content );
}
/**
* Echo img tag lazyloaded
* @param string $content Text content to be processed
* @return string Text content processed
*/
function italystrap_apply_lazyload( $content ) {
_deprecated_function( __FUNCTION__, '2.0', 'ItalyStrap\\\Core\\\apply_lazyload' );
echo ItalyStrapLazyload::add_image_placeholders( $content );
}
}