本文整理汇总了PHP中wr2x_get_retina函数的典型用法代码示例。如果您正苦于以下问题:PHP wr2x_get_retina函数的具体用法?PHP wr2x_get_retina怎么用?PHP wr2x_get_retina使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wr2x_get_retina函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __rocket_lazyload_replace_callback
/**
* Used to check if we have to LazyLoad this or not
*
* @since 2.5.5 Don't apply LazyLoad on images from WP Retina x2
* @since 2.5 Don't apply LazyLoad on all images from LayerSlider
* @since 2.4.2 Don't apply LazyLoad on all images from Media Grid
* @since 2.3.11 Don't apply LazyLoad on all images from Timthumb
* @since 2.3.10 Don't apply LazyLoad on all images from Revolution Slider & Justified Image Grid
* @since 2.3.8 Don't apply LazyLoad on captcha from Really Simple CAPTCHA
* @since 2.2
*/
function __rocket_lazyload_replace_callback($matches)
{
// Don't apply LazyLoad on images from WP Retina x2
if (function_exists('wr2x_picture_rewrite')) {
if (wr2x_get_retina(trailingslashit(ABSPATH) . wr2x_get_pathinfo_from_image_src(trim($matches[2], '"')))) {
return $matches[0];
}
}
// TO DO - improve this code with a preg_match - it's ugly!!!!
if (strpos($matches[1] . $matches[3], 'data-no-lazy=') === false && strpos($matches[1] . $matches[3], 'data-lazy-original=') === false && strpos($matches[1] . $matches[3], 'data-lazy-src=') === false && strpos($matches[1] . $matches[3], 'data-lazysrc=') === false && strpos($matches[1] . $matches[3], 'data-src=') === false && strpos($matches[1] . $matches[3], 'data-lazyload=') === false && strpos($matches[1] . $matches[3], 'data-bgposition=') === false && strpos($matches[2], '/wpcf7_captcha/') === false && strpos($matches[2], 'timthumb.php?src') === false && strpos($matches[1] . $matches[3], 'data-envira-src=') === false && strpos($matches[1] . $matches[3], 'fullurl=') === false && strpos($matches[1] . $matches[3], 'lazy-slider-img=') === false && strpos($matches[1] . $matches[3], 'srcset=') === false) {
/**
* Filter the LazyLoad placeholder on src attribute
*
* @since 2.6
*
* @param string Output that will be printed
*/
$placeholder = apply_filters('rocket_lazyload_placeholder', 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=');
$html = sprintf('<img%1$s src="%4$s" data-lazy-src=%2$s%3$s><noscript><img%1$s src=%2$s%3$s></noscript>', $matches[1], $matches[2], $matches[3], $placeholder);
/**
* Filter the LazyLoad HTML output on images
*
* @since 2.3.8
*
* @param string $html Output that will be printed
*/
$html = apply_filters('rocket_lazyload_html', $html, true);
return $html;
} else {
return $matches[0];
}
}
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:43,代码来源:lazyload.php
示例2: ewww_image_optimizer_resize_from_meta_data
//.........这里部分代码省略.........
}
}
if (!empty($already_optimized)) {
$ewww_debug .= "updating existing record, path: {$ims_path}, size: " . $image_size . "<br>";
// store info on the current image for future reference
$wpdb->update($wpdb->ewwwio_images, array('path' => $ims_path), array('id' => $already_optimized['id']));
$base_dir = $base_ims_dir;
}
}
}
// initialize $dup_size
$dup_size = false;
// check through all the sizes we've processed so far
foreach ($processed as $proc => $scan) {
// if a previous resize had identical dimensions
if ($scan['height'] == $data['height'] && $scan['width'] == $data['width']) {
// found a duplicate resize
$dup_size = true;
// point this resize at the same image as the previous one
$meta['sizes'][$size]['file'] = $meta['sizes'][$proc]['file'];
// and tell the user we didn't do any further optimization
$meta['sizes'][$size]['ewww_image_optimizer'] = __('No savings', EWWW_IMAGE_OPTIMIZER_DOMAIN);
}
}
// if this is a unique size
if (!$dup_size) {
$resize_path = $base_dir . $data['file'];
// run the optimization and store the results
list($optimized_file, $results, $resize_conv, $original) = ewww_image_optimizer($resize_path, $gallery_type, $conv, $new_image);
// if the resize was converted, store the result and the original filename in the metadata for later recovery
if ($resize_conv) {
// if we don't already have the update attachment filter
if (FALSE === has_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment')) {
// add the update attachment filter
add_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment', 10, 2);
}
$meta['sizes'][$size]['converted'] = 1;
$meta['sizes'][$size]['orig_file'] = str_replace($base_dir, '', $original);
$ewww_debug .= "original filename: {$original}<br>";
$meta['sizes'][$size]['real_orig_file'] = str_replace($base_dir, '', $resize_path);
$ewww_debug .= "resize path: {$resize_path}<br>";
}
if ($optimized_file !== false) {
// update the filename
$meta['sizes'][$size]['file'] = str_replace($base_dir, '', $optimized_file);
}
// update the optimization results
$meta['sizes'][$size]['ewww_image_optimizer'] = $results;
// optimize retina images, if they exist
if (function_exists('wr2x_get_retina') && ($retina_path = wr2x_get_retina($resize_path))) {
ewww_image_optimizer($retina_path, 4, false, false);
}
}
// store info on the sizes we've processed, so we can check the list for duplicate sizes
$processed[$size]['width'] = $data['width'];
$processed[$size]['height'] = $data['height'];
}
}
if (!empty($new_image)) {
$meta = ewww_image_optimizer_update_attachment_metadata($meta, $ID);
}
if (!preg_match('/' . __('Previously Optimized', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '/', $meta['ewww_image_optimizer']) && class_exists('Amazon_S3_And_CloudFront')) {
global $as3cf;
if (method_exists($as3cf, 'wp_update_attachment_metadata')) {
$as3cf->wp_update_attachment_metadata($meta, $ID);
} elseif (method_exists($as3cf, 'wp_generate_attachment_metadata')) {
$as3cf->wp_generate_attachment_metadata($meta, $ID);
}
$ewww_debug .= 'uploading to Amazon S3<br>';
}
if (class_exists('Cloudinary') && Cloudinary::config_get("api_secret") && ewww_image_optimizer_get_option('ewww_image_optimizer_enable_cloudinary') && !empty($new_image)) {
try {
$result = CloudinaryUploader::upload($file, array('use_filename' => True));
} catch (Exception $e) {
$error = $e->getMessage();
}
if (!empty($error)) {
$ewww_debug .= "Cloudinary error: {$error}<br>";
} else {
$ewww_debug .= "successfully uploaded to Cloudinary<br>";
// register the attachment in the database as a cloudinary attachment
$old_url = wp_get_attachment_url($ID);
wp_update_post(array('ID' => $ID, 'guid' => $result['url']));
update_attached_file($ID, $result['url']);
$meta['cloudinary'] = TRUE;
$errors = array();
// update the image location for the attachment
CloudinaryPlugin::update_image_src_all($ID, $result, $old_url, $result["url"], TRUE, $errors);
if (count($errors) > 0) {
$ewww_debug .= "Cannot migrate the following posts:<br>" . implode("<br>", $errors);
}
}
}
if ($log) {
ewww_image_optimizer_debug_log();
}
ewwwio_memory(__FUNCTION__);
// send back the updated metadata
return $meta;
}
开发者ID:goodbayscott,项目名称:wwr-temp,代码行数:101,代码来源:common.php
示例3: wr2x_get_retina_from_url
function wr2x_get_retina_from_url($url)
{
wr2x_log("[GRFU] From URL: " . $url, true);
$filepath = wr2x_from_url_to_system($url);
if (empty($filepath)) {
wr2x_log("[GRFU] To PATH: Not found", true);
return null;
}
wr2x_log("[GRFU] To PATH: " . $filepath, true);
$system_retina = wr2x_get_retina($filepath);
if (empty($system_retina)) {
wr2x_log("[GRFU] To Retina PATH: Not found", true);
return null;
}
wr2x_log("[GRFU]To Retina PATH: " . $system_retina, true);
$retina_url = wr2x_rewrite_url_to_retina($url);
wr2x_log("[GRFU]To Retina URL: " . $retina_url, true);
return $retina_url;
}
开发者ID:radscheit,项目名称:unicorn,代码行数:19,代码来源:wp-retina-2x.php
示例4: wr2x_html_rewrite
function wr2x_html_rewrite($buffer)
{
if (!isset($buffer) || trim($buffer) === '') {
return $buffer;
}
$doc = new DOMDocument();
@$doc->loadHTML($buffer);
// = ($doc->strictErrorChecking = false;)
$imageTags = $doc->getElementsByTagName('img');
foreach ($imageTags as $tag) {
//$img_info = parse_url( $tag->getAttribute('src') );
//$img_pathinfo = ltrim( $img_info['path'], '/' );
$img_pathinfo = wr2x_get_pathinfo_from_image_src($tag->getAttribute('src'));
$filepath = trailingslashit(ABSPATH) . $img_pathinfo;
$potential_retina = wr2x_get_retina($filepath);
if ($potential_retina != null) {
wr2x_log("Rewrite '{$filepath}' to '{$potential_retina}'.");
$retina_pathinfo = ltrim(str_replace(ABSPATH, "", $potential_retina), '/');
$buffer = str_replace($img_pathinfo, $retina_pathinfo, $buffer);
}
}
return $buffer;
}
开发者ID:brianmontecillo,项目名称:wordpress,代码行数:23,代码来源:wp-retina-2x.php
示例5: ewww_image_optimizer_resize_from_meta_data
//.........这里部分代码省略.........
// if this is a unique size
if (!$dup_size) {
$resize_path = $base_dir . $data['file'];
// run the optimization and store the results
if ($parallel_opt) {
touch($resize_path . '.processing');
$async_path = str_replace($upload_path, '', $resize_path);
add_filter('http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX);
$ewwwio_async_optimize_media->data(array('ewwwio_path' => $async_path, 'ewwwio_size' => $size, 'ewww_force' => $force))->dispatch();
$parallel_sizes[$size] = $resize_path;
} else {
list($optimized_file, $results, $resize_conv, $original) = ewww_image_optimizer($resize_path, $gallery_type, $conv, $new_image);
// if the resize was converted, store the result and the original filename in the metadata for later recovery
if ($resize_conv) {
// if we don't already have the update attachment filter
if (FALSE === has_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment')) {
// add the update attachment filter
add_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment', 10, 2);
}
$meta['sizes'][$size]['converted'] = 1;
$meta['sizes'][$size]['orig_file'] = str_replace($base_dir, '', $original);
ewwwio_debug_message("original filename: {$original}");
$meta['sizes'][$size]['real_orig_file'] = str_replace($base_dir, '', $resize_path);
ewwwio_debug_message("resize path: {$resize_path}");
}
if ($optimized_file !== false) {
// update the filename
$meta['sizes'][$size]['file'] = str_replace($base_dir, '', $optimized_file);
}
// update the optimization results
$meta['sizes'][$size]['ewww_image_optimizer'] = $results;
}
// optimize retina images, if they exist
if (function_exists('wr2x_get_retina') && ($retina_path = wr2x_get_retina($resize_path))) {
if ($parallel_opt) {
add_filter('http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX);
$async_path = str_replace($upload_path, '', $retina_path);
$ewwwio_async_optimize_media->data(array('path' => $async_path, 'size' => '', 'ewww_force' => $force))->dispatch();
} else {
ewww_image_optimizer($retina_path);
}
} else {
ewww_image_optimizer_hidpi_optimize($resize_path);
}
}
// store info on the sizes we've processed, so we can check the list for duplicate sizes
$processed[$size]['width'] = $data['width'];
$processed[$size]['height'] = $data['height'];
}
}
if (!empty($new_dimensions)) {
$prev_string = " - " . __('Previously Optimized', EWWW_IMAGE_OPTIMIZER_DOMAIN);
$meta['ewww_image_optimizer'] = preg_replace("/{$prev_string}/", '', $meta['ewww_image_optimizer']);
}
// process size from a custom theme
if (isset($meta['image_meta']['resized_images'])) {
$imagemeta_resize_pathinfo = pathinfo($file_path);
$imagemeta_resize_path = '';
foreach ($meta['image_meta']['resized_images'] as $imagemeta_resize) {
$imagemeta_resize_path = $imagemeta_resize_pathinfo['dirname'] . '/' . $imagemeta_resize_pathinfo['filename'] . '-' . $imagemeta_resize . '.' . $imagemeta_resize_pathinfo['extension'];
if ($parallel_opt) {
add_filter('http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX);
$async_path = str_replace($upload_path, '', $imagemeta_resize_path);
$ewwwio_async_optimize_media->data(array('path' => $async_path, 'size' => '', 'ewww_force' => $force))->dispatch();
} else {
ewww_image_optimizer($imagemeta_resize_path);
开发者ID:crazyyy,项目名称:bessarabia,代码行数:67,代码来源:common.php
示例6: parse_tiny_metadata
private function parse_tiny_metadata($tiny_metadata)
{
if (is_null($tiny_metadata)) {
$tiny_metadata = get_post_meta($this->id, self::META_KEY, true);
}
if ($tiny_metadata) {
foreach ($tiny_metadata as $size => $meta) {
if (!isset($this->sizes[$size])) {
if (self::is_retina($size) && Tiny_Settings::wr2x_active()) {
$retina_path = wr2x_get_retina($this->sizes[rtrim($size, '_wr2x')]->filename);
$this->sizes[$size] = new Tiny_Image_Size($retina_path);
} else {
$this->sizes[$size] = new Tiny_Image_Size();
}
}
$this->sizes[$size]->meta = $meta;
}
}
}
开发者ID:mattywebb,项目名称:cyclery-northside,代码行数:19,代码来源:class-tiny-image.php
注:本文中的wr2x_get_retina函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论