• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ewww_image_optimizer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ewww_added_new_image

 function ewww_added_new_image($image, $storage = null)
 {
     global $ewww_debug;
     $ewww_debug .= "<b>ewww_added_new_image()</b><br>";
     if (empty($storage)) {
         // creating the 'registry' object for working with nextgen
         $registry = C_Component_Registry::get_instance();
         // creating a database storage object from the 'registry' object
         $storage = $registry->get_utility('I_Gallery_Storage');
     }
     // find the image id
     if (is_array($image)) {
         $image_id = $image['id'];
         $image = $storage->object->_image_mapper->find($image_id, TRUE);
     } else {
         $image_id = $storage->object->_get_image_id($image);
     }
     $ewww_debug .= "image id: {$image_id}<br>";
     // get an array of sizes available for the $image
     $sizes = $storage->get_image_sizes();
     // run the optimizer on the image for each $size
     foreach ($sizes as $size) {
         if ($size === 'full') {
             $full_size = true;
         } else {
             $full_size = false;
         }
         // get the absolute path
         $file_path = $storage->get_image_abspath($image, $size);
         $ewww_debug .= "optimizing (nextgen): {$file_path}<br>";
         // optimize the image and grab the results
         $res = ewww_image_optimizer($file_path, 2, false, false, $full_size);
         $ewww_debug .= "results " . $res[1] . "<br>";
         // only if we're dealing with the full-size original
         if ($size === 'full') {
             // update the metadata for the optimized image
             $image->meta_data['ewww_image_optimizer'] = $res[1];
         } else {
             $image->meta_data[$size]['ewww_image_optimizer'] = $res[1];
         }
         nggdb::update_image_meta($image_id, $image->meta_data);
         $ewww_debug .= 'storing results for full size image<br>';
     }
     ewww_image_optimizer_debug_log();
     return $image;
 }
开发者ID:Rudchyk,项目名称:wp-framework,代码行数:46,代码来源:nextgen2-integration.php


示例2: ewww_image_optimizer_bulk_next

function ewww_image_optimizer_bulk_next($delay, $attachments)
{
    // toggle the resume flag to indicate an operation is in progress
    update_option('ewww_image_optimizer_bulk_ngg_resume', 'true');
    // need this file to work with metadata
    require_once WP_CONTENT_DIR . '/plugins/nextcellent-gallery-nextgen-legacy/lib/meta.php';
    foreach ($attachments as $id) {
        sleep($delay);
        // find out what time we started, in microseconds
        $started = microtime(true);
        // get the metadata
        $meta = new nggMeta($id);
        // retrieve the filepath
        $file_path = $meta->image->imagePath;
        // run the optimizer on the current image
        $fres = ewww_image_optimizer($file_path, 2, false, false, true);
        // update the metadata of the optimized image
        nggdb::update_image_meta($id, array('ewww_image_optimizer' => $fres[1]));
        // output the results of the optimization
        WP_CLI::line(__('Optimized image:', EWWW_IMAGE_OPTIMIZER_DOMAIN) . $meta->image->filename);
        WP_CLI::line(sprintf(__('Full size - %s', EWWW_IMAGE_OPTIMIZER_DOMAIN), html_entity_decode($fres[1])));
        // get the filepath of the thumbnail image
        $thumb_path = $meta->image->thumbPath;
        // run the optimization on the thumbnail
        $tres = ewww_image_optimizer($thumb_path, 2, false, true);
        // output the results of the thumb optimization
        WP_CLI::line(sprintf(__('Thumbnail - %s', EWWW_IMAGE_OPTIMIZER_DOMAIN), html_entity_decode($tres[1])));
        // outupt how much time we spent
        $elapsed = microtime(true) - $started;
        WP_CLI::line(sprintf(__('Elapsed: %.3f seconds', EWWW_IMAGE_OPTIMIZER_DOMAIN), $elapsed));
        // get the list of attachments remaining from the db
        $attachments = get_option('ewww_image_optimizer_bulk_ngg_attachments');
        // remove the first item
        if (!empty($attachments)) {
            array_shift($attachments);
        }
        // and store the list back in the db
        update_option('ewww_image_optimizer_bulk_ngg_attachments', $attachments, false);
    }
    // reset all the bulk options in the db
    update_option('ewww_image_optimizer_bulk_ngg_resume', '');
    update_option('ewww_image_optimizer_bulk_ngg_attachments', '', false);
    // and let the user know we are done
    WP_CLI::success(__('Finished Optimization!', EWWW_IMAGE_OPTIMIZER_DOMAIN));
}
开发者ID:aaronfrey,项目名称:PepperLillie-CVM,代码行数:45,代码来源:iocli.php


示例3: ewww_flag_bulk_loop

 function ewww_flag_bulk_loop()
 {
     if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can('edit_others_posts')) {
         wp_die(__('Cheatin&#8217; eh?', EWWW_IMAGE_OPTIMIZER_DOMAIN));
     }
     if (!empty($_REQUEST['sleep'])) {
         sleep($_REQUEST['sleep']);
     }
     // need this file to work with flag meta
     require_once WP_CONTENT_DIR . '/plugins/flash-album-gallery/lib/meta.php';
     // record the starting time for the current image (in microseconds)
     $started = microtime(true);
     $id = $_POST['attachment'];
     // get the image meta for the current ID
     $meta = new flagMeta($id);
     $file_path = $meta->image->imagePath;
     // optimize the full-size version
     $fres = ewww_image_optimizer($file_path, 3, false, false, ewww_image_optimizer_get_option('ewww_image_optimizer_lossy_skip_full'));
     $meta->image->meta_data['ewww_image_optimizer'] = $fres[1];
     // let the user know what happened
     printf("<p>" . __('Optimized image:', EWWW_IMAGE_OPTIMIZER_DOMAIN) . " <strong>%s</strong><br>", esc_html($meta->image->filename));
     printf(__('Full size – %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", $fres[1]);
     $thumb_path = $meta->image->thumbPath;
     // optimize the thumbnail
     $tres = ewww_image_optimizer($thumb_path, 3, false, true);
     $meta->image->meta_data['thumbnail']['ewww_image_optimizer'] = $tres[1];
     // and let the user know the results
     printf(__('Thumbnail – %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", $tres[1]);
     flagdb::update_image_meta($id, $meta->image->meta_data);
     // determine how much time the image took to process
     $elapsed = microtime(true) - $started;
     // and output it to the user
     printf(__('Elapsed: %.3f seconds', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</p>", $elapsed);
     // retrieve the list of attachments left to work on
     $attachments = get_option('ewww_image_optimizer_bulk_flag_attachments');
     // take the first image off the list
     if (!empty($attachments)) {
         array_shift($attachments);
     }
     // and send the list back to the db
     update_option('ewww_image_optimizer_bulk_flag_attachments', $attachments);
     die;
 }
开发者ID:LacieNat,项目名称:Access-Comm-Project,代码行数:43,代码来源:flag-integration.php


示例4: ewww_flag_bulk_loop

 function ewww_flag_bulk_loop()
 {
     global $ewww_defer;
     $ewww_defer = false;
     $output = array();
     $permissions = apply_filters('ewww_image_optimizer_bulk_permissions', '');
     if (!wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can($permissions)) {
         $output['error'] = esc_html__('Access token has expired, please reload the page.', EWWW_IMAGE_OPTIMIZER_DOMAIN);
         echo json_encode($output);
         die;
     }
     session_write_close();
     // find out if our nonce is on it's last leg/tick
     $tick = wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk');
     if ($tick === 2) {
         $output['new_nonce'] = wp_create_nonce('ewww-image-optimizer-bulk');
     } else {
         $output['new_nonce'] = '';
     }
     // need this file to work with flag meta
     require_once WP_CONTENT_DIR . '/plugins/flash-album-gallery/lib/meta.php';
     // record the starting time for the current image (in microseconds)
     $started = microtime(true);
     // retrieve the list of attachments left to work on
     $attachments = get_option('ewww_image_optimizer_bulk_flag_attachments');
     $id = array_shift($attachments);
     // get the image meta for the current ID
     $meta = new flagMeta($id);
     $file_path = $meta->image->imagePath;
     // optimize the full-size version
     $fres = ewww_image_optimizer($file_path, 3, false, false, true);
     $ewww_status = get_transient('ewww_image_optimizer_cloud_status');
     if (!empty($ewww_status) && preg_match('/exceeded/', $ewww_status)) {
         $output['error'] = esc_html__('License Exceeded', EWWW_IMAGE_OPTIMIZER_DOMAIN);
         echo json_encode($output);
         die;
     }
     $meta->image->meta_data['ewww_image_optimizer'] = $fres[1];
     // let the user know what happened
     $output['results'] = sprintf("<p>" . esc_html__('Optimized image:', EWWW_IMAGE_OPTIMIZER_DOMAIN) . " <strong>%s</strong><br>", esc_html($meta->image->filename));
     $output['results'] .= sprintf(esc_html__('Full size – %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", esc_html($fres[1]));
     if (!empty($meta->image->meta_data['webview'])) {
         // determine path of the webview
         $web_path = $meta->image->webimagePath;
         $wres = ewww_image_optimizer($web_path, 3, false, true);
         $meta->image->meta_data['webview']['ewww_image_optimizer'] = $wres[1];
         $output['results'] .= sprintf(esc_html__('Optimized size – %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", esc_html($wres[1]));
     }
     $thumb_path = $meta->image->thumbPath;
     // optimize the thumbnail
     $tres = ewww_image_optimizer($thumb_path, 3, false, true);
     $meta->image->meta_data['thumbnail']['ewww_image_optimizer'] = $tres[1];
     // and let the user know the results
     $output['results'] .= sprintf(esc_html__('Thumbnail – %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", esc_html($tres[1]));
     flagdb::update_image_meta($id, $meta->image->meta_data);
     // determine how much time the image took to process
     $elapsed = microtime(true) - $started;
     // and output it to the user
     $output['results'] .= sprintf(esc_html__('Elapsed: %.3f seconds', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</p>", $elapsed);
     // send the list back to the db
     update_option('ewww_image_optimizer_bulk_flag_attachments', $attachments, false);
     if (!empty($attachments)) {
         $next_attachment = array_shift($attachments);
         $next_file = $this->ewww_flag_bulk_filename($next_attachment);
         $loading_image = plugins_url('/images/wpspin.gif', __FILE__);
         if ($next_file) {
             $output['next_file'] = "<p>" . esc_html__('Optimizing', EWWW_IMAGE_OPTIMIZER_DOMAIN) . " <b>{$next_file}</b>&nbsp;<img src='{$loading_image}' alt='loading'/></p>";
         } else {
             $output['next_file'] = "<p>" . esc_html__('Optimizing', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "&nbsp;<img src='{$loading_image}' alt='loading'/></p>";
         }
     }
     echo json_encode($output);
     die;
 }
开发者ID:ChrisSargent,项目名称:moodesignz,代码行数:74,代码来源:flag-integration.php


示例5: wppa_optimize_image_file

function wppa_optimize_image_file($file)
{
    if (!wppa_switch('optimize_new')) {
        return;
    }
    if (function_exists('ewww_image_optimizer')) {
        ewww_image_optimizer($file, 4, false, false, false);
    }
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:9,代码来源:wppa-utils.php


示例6: ewww_ngg_optimize

 function ewww_ngg_optimize($id)
 {
     // retrieve the metadata for the image
     $meta = new nggMeta($id);
     // retrieve the image path
     $file_path = $meta->image->imagePath;
     // run the optimizer on the current image
     $fres = ewww_image_optimizer($file_path, 2, false, false, true);
     // update the metadata for the optimized image
     nggdb::update_image_meta($id, array('ewww_image_optimizer' => $fres[1]));
     // get the filepath of the thumbnail image
     $thumb_path = $meta->image->thumbPath;
     // run the optimization on the thumbnail
     $tres = ewww_image_optimizer($thumb_path, 2, false, true);
     return array($fres, $tres);
 }
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:16,代码来源:nextcellent-integration.php


示例7: ewww_flag_bulk_loop

 function ewww_flag_bulk_loop()
 {
     if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can('edit_others_posts')) {
         wp_die(__('Cheatin&#8217; eh?'));
     }
     // need this file to work with flag meta
     require_once WP_CONTENT_DIR . '/plugins/flash-album-gallery/lib/meta.php';
     // record the starting time for the current image (in microseconds)
     $started = microtime(true);
     $id = $_POST['attachment'];
     // get the image meta for the current ID
     $meta = new flagMeta($id);
     $file_path = $meta->image->imagePath;
     // optimize the full-size version
     $fres = ewww_image_optimizer($file_path, 3, false, false);
     // and store the results in the metadata
     flagdb::update_image_meta($id, array('ewww_image_optimizer' => $fres[1]));
     // let the user know what happened
     printf("<p>Optimized image: <strong>%s</strong><br>", esc_html($meta->image->filename));
     printf("Full size – %s<br>", $fres[1]);
     $thumb_path = $meta->image->thumbPath;
     // optimize the thumbnail
     $tres = ewww_image_optimizer($thumb_path, 3, false, true);
     // and let the user know the results
     printf("Thumbnail – %s<br>", $tres[1]);
     // determine how much time the image took to process
     $elapsed = microtime(true) - $started;
     // and output it to the user
     echo "Elapsed: " . round($elapsed, 3) . " seconds</p>";
     // retrieve the list of attachments left to work on
     $attachments = get_option('ewww_image_optimizer_bulk_flag_attachments');
     // take the first image off the list
     array_shift($attachments);
     // and send the list back to the db
     update_option('ewww_image_optimizer_bulk_flag_attachments', $attachments);
     die;
 }
开发者ID:Creative-Srijon,项目名称:top10bestwp,代码行数:37,代码来源:flag-integration.php


示例8: handle

 protected function handle()
 {
     session_write_close();
     if (empty($_POST['ewwwio_size'])) {
         $size = '';
     } else {
         $size = $_POST['ewwwio_size'];
     }
     if (!empty($_POST['ewwwio_path']) && $size == 'full') {
         $file_path = $this->find_file($_POST['ewwwio_path']);
         if (!empty($file_path)) {
             ewwwio_debug_message('processing async optimization request');
             list($file, $msg, $conv, $original) = ewww_image_optimizer($file_path, 1, false, false, true);
         } else {
             ewwwio_debug_message("could not process async optimization request for {$_POST['ewwwio_path']}");
         }
     } elseif (!empty($_POST['ewwwio_path'])) {
         $file_path = $this->find_file($_POST['ewwwio_path']);
         if (!empty($file_path)) {
             ewwwio_debug_message('processing async optimization request');
             list($file, $msg, $conv, $original) = ewww_image_optimizer($file_path);
         } else {
             ewwwio_debug_message("could not process async optimization request for {$_POST['ewwwio_path']}");
         }
     } else {
         ewwwio_debug_message('ignored async optimization request');
         return;
     }
     ewww_image_optimizer_hidpi_optimize($file_path);
     ewwwio_debug_message('checking for: ' . $file_path . '.processing');
     if (is_file($file_path . '.processing')) {
         ewwwio_debug_message('removing ' . $file_path . '.processing');
         unlink($file_path . '.processing');
     }
     ewww_image_optimizer_debug_log();
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:36,代码来源:background.php


示例9: generate_image_size

 function generate_image_size($image, $size, $params = null, $skip_defaults = false)
 {
     global $ewww_debug;
     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 = $this->object->get_image_abspath($image, $size);
         $filename = $success->fileName;
         ewww_image_optimizer($filename);
         //				ewww_image_optimizer_aux_images_loop( $filename, true );
         $ewww_debug .= "nextgen dynamic thumb saved: {$filename} <br>";
         $image_size = filesize($filename);
         $ewww_debug .= "optimized size: {$image_size} <br>";
     }
     ewww_image_optimizer_debug_log();
     ewwwio_memory(__FUNCTION__);
     return $success;
 }
开发者ID:jrald1291,项目名称:atu,代码行数:20,代码来源:nextgen2-integration.php


示例10: ewww_flag_bulk_loop

 function ewww_flag_bulk_loop()
 {
     global $ewww_defer;
     $ewww_defer = false;
     $permissions = apply_filters('ewww_image_optimizer_bulk_permissions', '');
     if (!wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can($permissions)) {
         wp_die(__('Access token has expired, please reload the page.', EWWW_IMAGE_OPTIMIZER_DOMAIN));
     }
     if (!empty($_REQUEST['ewww_sleep'])) {
         sleep($_REQUEST['ewww_sleep']);
     }
     // need this file to work with flag meta
     require_once WP_CONTENT_DIR . '/plugins/flash-album-gallery/lib/meta.php';
     // record the starting time for the current image (in microseconds)
     $started = microtime(true);
     $id = $_POST['ewww_attachment'];
     // get the image meta for the current ID
     $meta = new flagMeta($id);
     $file_path = $meta->image->imagePath;
     // optimize the full-size version
     $fres = ewww_image_optimizer($file_path, 3, false, false, true);
     global $ewww_exceed;
     if (!empty($ewww_exceed)) {
         echo '-9exceeded';
         die;
     }
     $meta->image->meta_data['ewww_image_optimizer'] = $fres[1];
     // let the user know what happened
     printf("<p>" . __('Optimized image:', EWWW_IMAGE_OPTIMIZER_DOMAIN) . " <strong>%s</strong><br>", esc_html($meta->image->filename));
     printf(__('Full size – %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", $fres[1]);
     if (!empty($meta->image->meta_data['webview'])) {
         // determine path of the webview
         $web_path = $meta->image->webimagePath;
         $wres = ewww_image_optimizer($web_path, 3, false, true);
         $meta->image->meta_data['webview']['ewww_image_optimizer'] = $wres[1];
         printf(__('Optimized size – %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", $wres[1]);
     }
     $thumb_path = $meta->image->thumbPath;
     // optimize the thumbnail
     $tres = ewww_image_optimizer($thumb_path, 3, false, true);
     $meta->image->meta_data['thumbnail']['ewww_image_optimizer'] = $tres[1];
     // and let the user know the results
     printf(__('Thumbnail – %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", $tres[1]);
     flagdb::update_image_meta($id, $meta->image->meta_data);
     // determine how much time the image took to process
     $elapsed = microtime(true) - $started;
     // and output it to the user
     printf(__('Elapsed: %.3f seconds', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</p>", $elapsed);
     // retrieve the list of attachments left to work on
     $attachments = get_option('ewww_image_optimizer_bulk_flag_attachments');
     // take the first image off the list
     if (!empty($attachments)) {
         array_shift($attachments);
     }
     // and send the list back to the db
     update_option('ewww_image_optimizer_bulk_flag_attachments', $attachments);
     die;
 }
开发者ID:crazyyy,项目名称:smartmagel,代码行数:58,代码来源:flag-integration.php


示例11: flickr_image_attach_deprecated

function flickr_image_attach_deprecated($flickrurl, $post_id)
{
    preg_match('/http\\:\\/\\/www\\.flickr\\.com\\/photos\\/(.*?)\\/([0-9]+)\\//si', $flickrurl, $m);
    if ($m) {
        $flickruser = $m[1];
        $photo_id = $m[2];
    } else {
        return;
    }
    //$flickruser = getFlickrUser($photo_id);
    $file = getFlickrURL($photo_id);
    if (!empty($file)) {
        // Download file to temp location
        $tmp = download_url($file);
        // Set variables for storage
        // fix file filename for query strings
        preg_match('/[^\\?]+\\.(jpe?g|jpe|gif|png)\\b/i', $file, $matches);
        $file_array['name'] = basename($matches[0]);
        $file_array['tmp_name'] = $tmp;
        // If error storing temporarily, unlink
        if (is_wp_error($tmp)) {
            @unlink($file_array['tmp_name']);
            $file_array['tmp_name'] = '';
        }
        // do the validation and storage stuff
        $id = media_handle_sideload($file_array, $post_id, $desc = null);
        // If error storing permanently, unlink
        if (is_wp_error($id)) {
            @unlink($file_array['tmp_name']);
            return $id;
        }
        $fullsize_path = get_attached_file($id);
        // Full path
        if (function_exists('ewww_image_optimizer')) {
            ewww_image_optimizer($fullsize_path, $gallery_type = 4, $converted = false, $new = true, $fullsize = true);
        }
        $src = wp_get_attachment_url($id);
    }
    if (!empty($src)) {
        update_post_meta($post_id, 'image_url_value', $flickrurl);
        update_post_meta($post_id, 'image_author_t_value', $flickruser);
        update_post_meta($post_id, 'image_value', $src);
        set_post_thumbnail($post_id, $id);
        return update_post_meta($post_id, 'Thumbnail', $src);
    } else {
        return false;
    }
}
开发者ID:Gestiopolis,项目名称:GestiopolisExp1,代码行数:48,代码来源:frontendedit.php


示例12: ewww_ngg_bulk_loop

 function ewww_ngg_bulk_loop()
 {
     if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can('edit_others_posts')) {
         wp_die(__('Cheatin&#8217; eh?'));
     }
     // need this file to work with metadata
     require_once WP_CONTENT_DIR . '/plugins/nextgen-gallery/lib/meta.php';
     // find out what time we started, in microseconds
     $started = microtime(true);
     $id = $_POST['attachment'];
     // get the metadata
     $meta = new nggMeta($id);
     // retrieve the filepath
     $file_path = $meta->image->imagePath;
     // run the optimizer on the current image
     $fres = ewww_image_optimizer($file_path, 2, false, false);
     // update the metadata of the optimized image
     nggdb::update_image_meta($id, array('ewww_image_optimizer' => $fres[1]));
     // output the results of the optimization
     printf("<p>Optimized image: <strong>%s</strong><br>", $meta->image->filename);
     printf("Full size - %s<br>", $fres[1]);
     // get the filepath of the thumbnail image
     $thumb_path = $meta->image->thumbPath;
     // run the optimization on the thumbnail
     $tres = ewww_image_optimizer($thumb_path, 2, false, true);
     // output the results of the thumb optimization
     printf("Thumbnail - %s<br>", $tres[1]);
     // outupt how much time we spent
     $elapsed = microtime(true) - $started;
     echo "Elapsed: " . round($elapsed, 3) . " seconds</p>";
     // get the list of attachments remaining from the db
     $attachments = get_option('ewww_image_optimizer_bulk_ngg_attachments');
     // remove the first item
     array_shift($attachments);
     // and store the list back in the db
     update_option('ewww_image_optimizer_bulk_ngg_attachments', $attachments);
     die;
 }
开发者ID:Creative-Srijon,项目名称:top10bestwp,代码行数:38,代码来源:nextgen-integration.php


示例13: 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, $background_new = false)
{
    ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
    if (!is_array($meta) && empty($meta)) {
        $meta = array();
    } elseif (!is_array($meta)) {
        if (is_string($meta) && is_int($ID) && 'processing' == $meta) {
            ewwwio_debug_message("attempting to rebuild attachment meta for {$ID}");
            $new_meta = ewww_image_optimizer_rebuild_meta($ID);
            if (!is_array($new_meta)) {
                ewwwio_debug_message('attempt to rebuild attachment meta failed');
                return $meta;
            } else {
                $meta = $new_meta;
            }
        } else {
            ewwwio_debug_message('attachment meta is not a usable array');
            return $meta;
        }
    } elseif (is_array($meta) && !empty($meta[0]) && 'processing' == $meta[0]) {
        ewwwio_debug_message("attempting to rebuild attachment meta for {$ID}");
        $new_meta = ewww_image_optimizer_rebuild_meta($ID);
        if (!is_array($new_meta)) {
            ewwwio_debug_message('attempt to rebuild attachment meta failed');
            return $meta;
        } else {
            $meta = $new_meta;
        }
    }
    global $wpdb;
    global $ewww_defer;
    global $ewww_new_image;
    $gallery_type = 1;
    ewwwio_debug_message("attachment id: {$ID}");
    session_write_close();
    //if ( ! metadata_exists( 'post', $ID, '_wp_attachment_metadata' ) ) {
    if (!empty($ewww_new_image)) {
        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}");
    $type = ewww_image_optimizer_mimetype($file_path, 'i');
    $supported_types = array('image/jpeg', 'image/png', 'image/gif', 'application/pdf');
    if (!in_array($type, $supported_types)) {
        ewwwio_debug_message("mimetype not supported: {$ID}");
        return $meta;
    }
    // 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);
        $already_optimized = ewww_image_optimizer_find_already_optimized($imsanity_path);
        if (is_array($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 ((!empty($new_image) || ewww_image_optimizer_get_option('ewww_image_optimizer_resize_existing')) && !function_exists('imsanity_get_max_width_height')) {
        $new_dimensions = ewww_image_optimizer_resize_upload($file_path);
        if (is_array($new_dimensions)) {
            $meta['width'] = $new_dimensions[0];
            $meta['height'] = $new_dimensions[1];
        }
    }
    if ($ewww_defer && !ewww_image_optimizer_detect_wpsf_location_lock()) {
//.........这里部分代码省略.........
开发者ID:crazyyy,项目名称:bessarabia,代码行数:101,代码来源:common.php


示例14: 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)
{
    global $ewww_debug;
    $ewww_debug = "{$ewww_debug} <b>ewww_image_optimizer_resize_from_meta_data()</b><br>";
    // don't do anything else if the attachment has no metadata
    if (!isset($meta['file'])) {
        $ewww_debug = "{$ewww_debug} file has no meta<br>";
        return $meta;
    }
    if (FALSE === has_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_saved_file')) {
        $gallery_type = 1;
    } else {
        $gallery_type = 5;
    }
    // get the filepath from the metadata
    $file_path = $meta['file'];
    $ewww_debug = "{$ewww_debug} meta file path: {$file_path}<br>";
    // store absolute paths for older wordpress versions
    $store_absolute_path = true;
    // retrieve the location of the wordpress upload folder
    $upload_dir = wp_upload_dir();
    // retrieve the path of the upload folder
    $upload_path = trailingslashit($upload_dir['basedir']);
    // if the path given is not the absolute path
    if (FALSE == file_exists($file_path)) {
        // don't store absolute paths
        $store_absolute_path = false;
        // generate the absolute path
        $file_path = $upload_path . $file_path;
        $ewww_debug = "{$ewww_debug} generated absolute path: {$file_path}<br>";
    }
    // run the image optimizer on the file, and store the results
    list($file, $msg, $conv, $original) = ewww_image_optimizer($file_path, $gallery_type, false, false);
    // update the filename in the metadata
    $meta['file'] = $file;
    // update the optimization results in the metadata
    $meta['ewww_image_optimizer'] = $msg;
    // strip absolute path for Wordpress >= 2.6.2
    if (FALSE === $store_absolute_path) {
        $meta['file'] = str_replace($upload_path, '', $meta['file']);
    }
    // if the file was converted
    if ($conv) {
        $ewww_debug = "{$ewww_debug} image was converted<br>";
        // 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;
    } else {
        remove_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment', 10);
    }
    // resized versions, so we can continue
    if (isset($meta['sizes'])) {
        $ewww_debug = "{$ewww_debug} processing resizes<br>";
        // meta sizes don't contain a path, so we calculate one
        $base_dir = dirname($file_path) . '/';
        // process each resized version
        $processed = array();
        foreach ($meta['sizes'] as $size => $data) {
            // 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';
                }
            }
            // if this is a unique size
            if (!$dup_size) {
                // run the optimization and store the results
                list($optimized_file, $results, $resize_conv, $original) = ewww_image_optimizer($base_dir . $data['file'], $gallery_type, $conv, true);
                // 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);
//.........这里部分代码省略.........
开发者ID:Creative-Srijon,项目名称:top10bestwp,代码行数:101,代码来源:ewww-image-optimizer.php


示例15: 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


示例16: 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)
{
    global $ewww_debug;
    global $wpdb;
    // may also need to track their attachment ID as well
    $ewww_debug .= "<b>ewww_image_optimizer_resize_from_meta_data()</b><br>";
    $gallery_type = 1;
    $ewww_debug .= "attachment id: {$ID}<br>";
    if (!metadata_exists('post', $ID, '_wp_attachment_metadata')) {
        $ewww_debug .= "this is a newly uploaded image with no metadata yet<br>";
        $new_image = true;
    } else {
        $ewww_debug .= "this image already has metadata, so it is not new<br>";
        $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;
    }
    // don't do anything else if the attachment path can't be retrieved
    if (!is_file($file_path)) {
        $ewww_debug .= "could not retrieve path<br>";
        return $meta;
    }
    $ewww_debug .= "retrieved file path: {$file_path}<br>";
    // 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'];
        $ewww_debug .= "imsanity path: {$imsanity_path}<br>";
        $image_size = 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) {
                    $ewww_debug .= "{$image['path']} does not match {$imsanity_path}, continuing our search<br>";
                } else {
                    $already_optimized = $image;
                }
            }
        }
        if (!empty($already_optimized)) {
            $ewww_debug .= "updating existing record, path: {$file_path}, size: " . $image_size . "<br>";
            // store info on the current image for future reference
            $wpdb->update($wpdb->ewwwio_images, array('path' => $file_path), array('id' => $already_optimized['id']));
        }
    }
    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;
    }
    $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;
        $ewww_debug .= "image was converted<br>";
        // 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;
    } else {
        remove_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment', 10);
    }
    // resized versions, so we can continue
    if (isset($meta['sizes'])) {
        $disabled_sizes = ewww_image_optimizer_get_option('ewww_image_optimizer_disable_resizes_opt');
        $ewww_debug .= "disabled sizes: " . print_r($disabled_sizes, true) . "<br>";
        $ewww_debug .= "processing resizes<br>";
        // meta sizes don't contain a path, so we calculate one
        if ($gallery_type === 6) {
            $base_ims_dir = dirname($file_path) . '/_resized/';
        }
        $base_dir = dirname($file_path) . '/';
        // process each resized version
        $processed = array();
//.........这里部分代码省略.........
开发者ID:goodbayscott,项目名称:wwr-temp,代码行数:101,代码来源:common.php


示例17: wppa_do_maintenance_proc


//.........这里部分代码省略.........
                            break;
                        case 'wppa_add_gpx_tag':
                            $tags = $photo['tags'];
                            $temp = explode('/', $photo['location']);
                            if (!isset($temp['2'])) {
                                $temp['2'] = false;
                            }
                            if (!isset($temp['3']))  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ewww_image_optimizer_add_deferred_attachment函数代码示例发布时间:2022-05-15
下一篇:
PHP ewrpt_StripSlashes函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap