当前位置: 首页>>代码示例>>PHP>>正文


PHP ewww_image_optimizer_add_deferred_attachment函数代码示例

本文整理汇总了PHP中ewww_image_optimizer_add_deferred_attachment函数的典型用法代码示例。如果您正苦于以下问题:PHP ewww_image_optimizer_add_deferred_attachment函数的具体用法?PHP ewww_image_optimizer_add_deferred_attachment怎么用?PHP ewww_image_optimizer_add_deferred_attachment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ewww_image_optimizer_add_deferred_attachment函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ewww_ngg_image_save

 function ewww_ngg_image_save($filename)
 {
     ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
     global $ewww_defer;
     if (file_exists($filename)) {
         if ($ewww_defer && ewww_image_optimizer_get_option('ewww_image_optimizer_defer')) {
             ewww_image_optimizer_add_deferred_attachment("file,{$filename}");
             return $saved;
         }
         ewww_image_optimizer($filename);
         ewwwio_debug_message("ngg_Thumbnail saved: {$filename}");
         $image_size = ewww_image_optimizer_filesize($filename);
         ewwwio_debug_message("image editor size: {$image_size}");
     }
     ewww_image_optimizer_debug_log();
     ewwwio_memory(__FUNCTION__);
 }
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:17,代码来源:nextcellent-integration.php

示例2: ewww_added_new_image_slow

 function ewww_added_new_image_slow($image)
 {
     // query the filesystem path of the gallery from the database
     global $ewww_defer;
     global $wpdb;
     $q = $wpdb->prepare("SELECT path FROM {$wpdb->prefix}ngg_gallery WHERE gid = %d LIMIT 1", $image['galleryID']);
     $gallery_path = $wpdb->get_var($q);
     // if we have a path to work with
     if ($gallery_path) {
         // construct the absolute path of the current image
         $file_path = trailingslashit($gallery_path) . $image['filename'];
         if ($ewww_defer && ewww_image_optimizer_get_option('ewww_image_optimizer_defer')) {
             ewww_image_optimizer_add_deferred_attachment("nextcellent,{$image['id']}");
             return;
         }
         // run the optimizer on the current image
         $res = ewww_image_optimizer(ABSPATH . $file_path, 2, false, false, true);
         // update the metadata for the optimized image
         nggdb::update_image_meta($image['id'], array('ewww_image_optimizer' => $res[1]));
     }
 }
开发者ID:aaronfrey,项目名称:PepperLillie-CVM,代码行数:21,代码来源:nextcellent-integration.php

示例3: generate_image_size

 function generate_image_size($image, $size, $params = null, $skip_defaults = false)
 {
     ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
     global $ewww_defer;
     if (!defined('EWWW_IMAGE_OPTIMIZER_CLOUD')) {
         ewww_image_optimizer_init();
     }
     $success = $this->call_parent('generate_image_size', $image, $size, $params, $skip_defaults);
     if ($success) {
         $filename = $success->fileName;
         if ($ewww_defer && ewww_image_optimizer_get_option('ewww_image_optimizer_defer')) {
             ewww_image_optimizer_add_deferred_attachment("file,{$filename}");
             return $saved;
         }
         ewww_image_optimizer($filename);
         ewwwio_debug_message("nextgen dynamic thumb saved: {$filename}");
         $image_size = ewww_image_optimizer_filesize($filename);
         ewwwio_debug_message("optimized size: {$image_size}");
     }
     ewww_image_optimizer_debug_log();
     ewwwio_memory(__FUNCTION__);
     return $success;
 }
开发者ID:agiper,项目名称:wordpress,代码行数:23,代码来源:nextgen2-integration.php

示例4: ewww_image_optimizer_resize_from_meta_data

/**
 * Read the image paths from an attachment's meta data and process each image
 * with ewww_image_optimizer().
 *
 * This method also adds a `ewww_image_optimizer` meta key for use in the media library 
 * and may add a 'converted' and 'orig_file' key if conversion is enabled.
 *
 * Called after `wp_generate_attachment_metadata` is completed.
 */
function ewww_image_optimizer_resize_from_meta_data($meta, $ID = null, $log = true)
{
    ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
    if (!is_array($meta)) {
        ewwwio_debug_message('attachment meta is not a usable array');
        return $meta;
    }
    global $wpdb;
    global $ewww_defer;
    $gallery_type = 1;
    ewwwio_debug_message("attachment id: {$ID}");
    if (!metadata_exists('post', $ID, '_wp_attachment_metadata')) {
        ewwwio_debug_message('this is a newly uploaded image with no metadata yet');
        $new_image = true;
    } else {
        ewwwio_debug_message('this image already has metadata, so it is not new');
        $new_image = false;
    }
    list($file_path, $upload_path) = ewww_image_optimizer_attachment_path($meta, $ID);
    // if the attachment has been uploaded via the image store plugin
    if ('ims_image' == get_post_type($ID)) {
        $gallery_type = 6;
    }
    if (!$new_image && class_exists('Amazon_S3_And_CloudFront') && strpos($file_path, 's3') === 0) {
        ewww_image_optimizer_check_table_as3cf($meta, $ID, $file_path);
    }
    // if the local file is missing and we have valid metadata, see if we can fetch via CDN
    if (!is_file($file_path) || strpos($file_path, 's3') === 0) {
        $file_path = ewww_image_optimizer_remote_fetch($ID, $meta);
        if (!$file_path) {
            ewwwio_debug_message('could not retrieve path');
            $meta['ewww_image_optimizer'] = __('Could not find image', EWWW_IMAGE_OPTIMIZER_DOMAIN);
            return $meta;
        }
    }
    ewwwio_debug_message("retrieved file path: {$file_path}");
    // see if this is a new image and Imsanity resized it (which means it could be already optimized)
    if (!empty($new_image) && function_exists('imsanity_get_max_width_height')) {
        list($maxW, $maxH) = imsanity_get_max_width_height(IMSANITY_SOURCE_LIBRARY);
        list($oldW, $oldH) = getimagesize($file_path);
        list($newW, $newH) = wp_constrain_dimensions($oldW, $oldH, $maxW, $maxH);
        $path_parts = pathinfo($file_path);
        $imsanity_path = trailingslashit($path_parts['dirname']) . $path_parts['filename'] . '-' . $newW . 'x' . $newH . '.' . $path_parts['extension'];
        ewwwio_debug_message("imsanity path: {$imsanity_path}");
        $image_size = ewww_image_optimizer_filesize($file_path);
        $query = $wpdb->prepare("SELECT id,path FROM {$wpdb->ewwwio_images} WHERE path = %s AND image_size = '{$image_size}'", $imsanity_path);
        $optimized_query = $wpdb->get_results($query, ARRAY_A);
        if (!empty($optimized_query)) {
            foreach ($optimized_query as $image) {
                if ($image['path'] != $imsanity_path) {
                    ewwwio_debug_message("{$image['path']} does not match {$imsanity_path}, continuing our search");
                } else {
                    $already_optimized = $image;
                }
            }
        }
        if (!empty($already_optimized)) {
            ewwwio_debug_message("updating existing record, path: {$file_path}, size: " . $image_size);
            // store info on the current image for future reference
            $wpdb->update($wpdb->ewwwio_images, array('path' => $file_path), array('id' => $already_optimized['id']));
        }
    }
    if ($ewww_defer && ewww_image_optimizer_get_option('ewww_image_optimizer_defer')) {
        ewww_image_optimizer_add_deferred_attachment("media,{$ID}");
        return $meta;
    }
    list($file, $msg, $conv, $original) = ewww_image_optimizer($file_path, $gallery_type, false, $new_image, true);
    // update the optimization results in the metadata
    $meta['ewww_image_optimizer'] = $msg;
    if ($file === false) {
        return $meta;
    }
    ewww_image_optimizer_hidpi_optimize($file_path);
    $meta['file'] = str_replace($upload_path, '', $file);
    // if the file was converted
    if ($conv) {
        // update the filename in the metadata
        $new_file = substr($meta['file'], 0, -3);
        // change extension
        $new_ext = substr($file, -3);
        $meta['file'] = $new_file . $new_ext;
        ewwwio_debug_message('image was converted');
        // 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);
        }
        // store the conversion status in the metadata
        $meta['converted'] = 1;
        // store the old filename in the database
        $meta['orig_file'] = $original;
//.........这里部分代码省略.........
开发者ID:amprog,项目名称:ewww-image-optimizer,代码行数:101,代码来源:common.php

示例5: ewww_added_new_image

 function ewww_added_new_image($image)
 {
     ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
     global $ewww_defer;
     // make sure the image path is set
     if (isset($image->imagePath)) {
         // get the image ID
         $pid = $image->pid;
         if ($ewww_defer && ewww_image_optimizer_get_option('ewww_image_optimizer_defer')) {
             ewww_image_optimizer_add_deferred_attachment("flag,{$pid}");
             return;
         }
         // optimize the full size
         $res = ewww_image_optimizer($image->imagePath, 3, false, false, true);
         // optimize the web optimized version
         $wres = ewww_image_optimizer($image->webimagePath, 3, false, true);
         // optimize the thumbnail
         $tres = ewww_image_optimizer($image->thumbPath, 3, false, true);
         // retrieve the metadata for the image ID
         $meta = new flagMeta($pid);
         ewwwio_debug_message(print_r($meta->image->meta_data, TRUE));
         $meta->image->meta_data['ewww_image_optimizer'] = $res[1];
         if (!empty($meta->image->meta_data['webview'])) {
             $meta->image->meta_data['webview']['ewww_image_optimizer'] = $wres[1];
         }
         $meta->image->meta_data['thumbnail']['ewww_image_optimizer'] = $tres[1];
         // update the image metadata in the db
         flagdb::update_image_meta($pid, $meta->image->meta_data);
     }
     ewww_image_optimizer_debug_log();
 }
开发者ID:agiper,项目名称:wordpress,代码行数:31,代码来源:flag-integration.php


注:本文中的ewww_image_optimizer_add_deferred_attachment函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。