@ 2015-12-21T07:34:43Z <?php
function get_tumbail($imgSrc,$placeholder_image){
$imgPattern = "/(http\:\/\/ww\d+\.sinaimg\.cn\/)(\w+)(\/\S+\.(jpg|gif))/i";
$matches = null;
$result = preg_match($imgPattern, $imgSrc, $matches);
if (!$result) {
return $placeholder_image;
}
return $matches[1] . 'thumbnail' . $matches[3];
}
$placeholder_image = 'images/transparent.gif';
$imgStr = '<img src="http://ww2.sinaimg.cn/bmiddle/a3d444e3jw1ez79amvdi1j20l50s8gpl.jpg"/>';
$imgStr = preg_replace_callback('#<img([^>]+?)src=[\'"]?([^\'"\s>]+)[\'"]?([^>]*)>#',function($match) {
var_dump($match);
global $placeholder_image;
return sprintf('<img'.$match[1].'src="%s" data-original="'.$match[2].'" class="lazy"'.$match[3].'><noscript><img'.$match[1].'src="'.$match[2].'"'.$match[3].'></noscript>', get_tumbail($match[2],$placeholder_image));
},$imgStr);
var_dump($imgStr);
$imgStr = preg_replace('#<img([^>]+?)src=[\'"]?([^\'"\s>]+)[\'"]?([^>]*)>#', sprintf('<img${1}src="%s" data-original="${2}" class="lazy"${3}><noscript><img${1}src="${2}"${3}></noscript>', get_tumbail($2,$placeholder_image)), $imgStr);
var_dump($imgStr);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.0.1 0.007 0.040 20.26 7.0.0 0.007 0.040 20.12 5.6.16 0.003 0.053 20.54 5.6.15 0.017 0.060 18.15 5.6.14 0.007 0.080 18.18 5.6.13 0.010 0.060 18.14 5.6.12 0.013 0.080 21.02 5.6.11 0.010 0.083 21.02 5.6.10 0.003 0.047 21.04 5.6.9 0.003 0.087 21.01 5.6.8 0.010 0.073 20.38 5.5.30 0.007 0.037 18.07 5.5.29 0.013 0.077 18.08 5.5.28 0.003 0.080 20.75 5.5.27 0.010 0.073 20.89 5.5.26 0.013 0.050 20.79 5.5.25 0.020 0.070 20.67 5.5.24 0.013 0.077 20.08
preferences:dark mode live preview
138.38 ms | 1394 KiB | 7 Q