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


PHP ewww_image_optimizer_debug_log函数代码示例

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


在下文中一共展示了ewww_image_optimizer_debug_log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
     $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:hkarriche,项目名称:wordpress,代码行数:41,代码来源:nextgen2-integration.php

示例2: ewww_image_optimizer_update_attachment

/**
 * Update the attachment's meta data after being converted 
 */
function ewww_image_optimizer_update_attachment($meta, $ID)
{
    ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
    global $wpdb;
    // update the file location in the post metadata based on the new path stored in the attachment metadata
    update_attached_file($ID, $meta['file']);
    $guid = wp_get_attachment_url($ID);
    if (empty($meta['real_orig_file'])) {
        $old_guid = dirname($guid) . "/" . basename($meta['orig_file']);
    } else {
        $old_guid = dirname($guid) . "/" . basename($meta['real_orig_file']);
        unset($meta['real_orig_file']);
    }
    // construct the new guid based on the filename from the attachment metadata
    ewwwio_debug_message("old guid: {$old_guid}");
    ewwwio_debug_message("new guid: {$guid}");
    if (substr($old_guid, -1) == '/' || substr($guid, -1) == '/') {
        ewwwio_debug_message('could not obtain full url for current and previous image, bailing');
        return $meta;
    }
    // retrieve any posts that link the image
    $esql = $wpdb->prepare("SELECT ID, post_content FROM {$wpdb->posts} WHERE post_content LIKE '%%%s%%'", $old_guid);
    ewwwio_debug_message("using query: {$esql}");
    // while there are posts to process
    $rows = $wpdb->get_results($esql, ARRAY_A);
    foreach ($rows as $row) {
        // replace all occurences of the old guid with the new guid
        $post_content = str_replace($old_guid, $guid, $row['post_content']);
        ewwwio_debug_message("replacing {$old_guid} with {$guid} in post " . $row['ID']);
        // send the updated content back to the database
        $wpdb->update($wpdb->posts, array('post_content' => $post_content), array('ID' => $row['ID']));
    }
    if (isset($meta['sizes'])) {
        // for each resized version
        foreach ($meta['sizes'] as $size => $data) {
            // if the resize was converted
            if (isset($data['converted'])) {
                // generate the url for the old image
                if (empty($data['real_orig_file'])) {
                    $old_sguid = dirname($old_guid) . "/" . basename($data['orig_file']);
                } else {
                    $old_sguid = dirname($old_guid) . "/" . basename($data['real_orig_file']);
                    unset($meta['sizes'][$size]['real_orig_file']);
                }
                ewwwio_debug_message("processing: {$size}");
                ewwwio_debug_message("old sguid: {$old_sguid}");
                // generate the url for the new image
                $sguid = dirname($old_guid) . "/" . basename($data['file']);
                ewwwio_debug_message("new sguid: {$sguid}");
                if (substr($old_sguid, -1) == '/' || substr($sguid, -1) == '/') {
                    ewwwio_debug_message('could not obtain full url for current and previous resized image, bailing');
                    continue;
                }
                // retrieve any posts that link the resize
                $ersql = $wpdb->prepare("SELECT ID, post_content FROM {$wpdb->posts} WHERE post_content LIKE '%%%s%%'", $old_sguid);
                //ewwwio_debug_message( "using query: $ersql" );
                $rows = $wpdb->get_results($ersql, ARRAY_A);
                // while there are posts to process
                foreach ($rows as $row) {
                    // replace all occurences of the old guid with the new guid
                    $post_content = str_replace($old_sguid, $sguid, $row['post_content']);
                    ewwwio_debug_message("replacing {$old_sguid} with {$sguid} in post " . $row['ID']);
                    // send the updated content back to the database
                    $wpdb->update($wpdb->posts, array('post_content' => $post_content), array('ID' => $row['ID']));
                }
            }
        }
    }
    // if the new image is a JPG
    if (preg_match('/.jpg$/i', basename($meta['file']))) {
        // set the mimetype to JPG
        $mime = 'image/jpg';
    }
    // if the new image is a PNG
    if (preg_match('/.png$/i', basename($meta['file']))) {
        // set the mimetype to PNG
        $mime = 'image/png';
    }
    if (preg_match('/.gif$/i', basename($meta['file']))) {
        // set the mimetype to GIF
        $mime = 'image/gif';
    }
    // update the attachment post with the new mimetype and id
    wp_update_post(array('ID' => $ID, 'post_mime_type' => $mime));
    ewww_image_optimizer_debug_log();
    ewwwio_memory(__FUNCTION__);
    return $meta;
}
开发者ID:amprog,项目名称:ewww-image-optimizer,代码行数:91,代码来源:common.php

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

示例4: ewww_image_optimizer_bulk_loop

function ewww_image_optimizer_bulk_loop()
{
    global $ewww_debug;
    global $ewww_exceed;
    // verify that an authorized user has started the optimizer
    $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(__('Cheatin&#8217; eh?', EWWW_IMAGE_OPTIMIZER_DOMAIN));
    }
    if (!empty($_REQUEST['ewww_sleep'])) {
        sleep($_REQUEST['ewww_sleep']);
    }
    // retrieve the time when the optimizer starts
    $started = microtime(true);
    // get the attachment ID of the current attachment
    $attachment = $_POST['ewww_attachment'];
    // get the 'bulk attachments' with a list of IDs remaining
    $attachments = get_option('ewww_image_optimizer_bulk_attachments');
    $meta = wp_get_attachment_metadata($attachment, true);
    // do the optimization for the current attachment (including resizes)
    $meta = ewww_image_optimizer_resize_from_meta_data($meta, $attachment, false);
    if (!empty($ewww_exceed)) {
        echo '-9exceeded';
        die;
    }
    if (!empty($meta['file'])) {
        // output the filename (and path relative to 'uploads' folder)
        printf("<p>" . __('Optimized image:', EWWW_IMAGE_OPTIMIZER_DOMAIN) . " <strong>%s</strong><br>", esc_html($meta['file']));
    } else {
        printf("<p>" . __('Skipped image, ID:', EWWW_IMAGE_OPTIMIZER_DOMAIN) . " <strong>%s</strong><br>", $attachment);
    }
    if (!empty($meta['ewww_image_optimizer'])) {
        // tell the user what the results were for the original image
        printf(__('Full size – %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", $meta['ewww_image_optimizer']);
    }
    // check to see if there are resized version of the image
    if (isset($meta['sizes']) && is_array($meta['sizes'])) {
        // cycle through each resize
        foreach ($meta['sizes'] as $size) {
            if (!empty($size['ewww_image_optimizer'])) {
                // output the results for the current resized version
                printf("%s – %s<br>", $size['file'], $size['ewww_image_optimizer']);
            }
        }
    }
    // calculate how much time has elapsed since we started
    $elapsed = microtime(true) - $started;
    // output how much time has elapsed since we started
    printf(__('Elapsed: %.3f seconds', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</p>", $elapsed);
    global $ewww_attachment;
    $ewww_attachment['id'] = $attachment;
    $ewww_attachment['meta'] = $meta;
    add_filter('w3tc_cdn_update_attachment_metadata', 'ewww_image_optimizer_w3tc_update_files');
    // update the metadata for the current attachment
    wp_update_attachment_metadata($attachment, $meta);
    // remove the first element from the $attachments array
    if (!empty($attachments)) {
        array_shift($attachments);
    }
    // store the updated list of attachment IDs back in the 'bulk_attachments' option
    update_option('ewww_image_optimizer_bulk_attachments', $attachments);
    if (ewww_image_optimizer_get_option('ewww_image_optimizer_debug')) {
        echo '<div style="background-color:#ffff99;">' . $ewww_debug . '</div>';
    }
    ewww_image_optimizer_debug_log();
    ewwwio_memory(__FUNCTION__);
    die;
}
开发者ID:Rudchyk,项目名称:wp-framework,代码行数:68,代码来源:bulk.php

示例5: ewww_added_new_image

 function ewww_added_new_image($image)
 {
     global $ewww_debug;
     $ewww_debug .= "<b>ewww_flag::ewww_added_new_image()</b><br>";
     // make sure the image path is set
     if (isset($image->imagePath)) {
         // 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);
         // get the image ID
         $pid = $image->pid;
         // retrieve the metadata for the image ID
         $meta = new flagMeta($pid);
         $ewww_debug .= print_r($meta->image->meta_data, TRUE) . "<br>";
         $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:goodbayscott,项目名称:wwr-temp,代码行数:27,代码来源:flag-integration.php

示例6: ewww_image_optimizer_update_attachment

/**
 * Update the attachment's meta data after being converted 
 */
function ewww_image_optimizer_update_attachment($meta, $ID)
{
    global $ewww_debug;
    global $wpdb;
    $ewww_debug .= "<b>ewww_image_optimizer_update_attachment()</b><br>";
    // update the file location in the post metadata based on the new path stored in the attachment metadata
    update_attached_file($ID, $meta['file']);
    // retrieve the post information based on the $ID
    $post = get_post($ID);
    // save the previous attachment address
    $old_guid = $post->guid;
    // construct the new guid based on the filename from the attachment metadata
    $guid = dirname($post->guid) . "/" . basename($meta['file']);
    // retrieve any posts that link the image
    $esql = $wpdb->prepare("SELECT ID, post_content FROM {$wpdb->posts} WHERE post_content LIKE '%%%s%%'", $old_guid);
    // while there are posts to process
    $rows = $wpdb->get_results($esql, ARRAY_A);
    foreach ($rows as $row) {
        // replace all occurences of the old guid with the new guid
        $post_content = str_replace($old_guid, $guid, $row['post_content']);
        $ewww_debug .= "replacing {$old_guid} with {$guid} in post " . $row['ID'] . '<br>';
        // send the updated content back to the database
        $wpdb->update($wpdb->posts, array('post_content' => $post_content), array('ID' => $row['ID']));
    }
    if (isset($meta['sizes'])) {
        // for each resized version
        foreach ($meta['sizes'] as $size => $data) {
            // if the resize was converted
            if (isset($data['converted'])) {
                // generate the url for the old image
                if (empty($data['real_orig_file'])) {
                    $old_sguid = dirname($post->guid) . "/" . basename($data['orig_file']);
                } else {
                    $old_sguid = dirname($post->guid) . "/" . basename($data['real_orig_file']);
                    unset($meta['sizes'][$size]['real_orig_file']);
                }
                $ewww_debug .= "processing: {$size}<br>";
                $ewww_debug .= "old guid: {$old_sguid} <br>";
                // generate the url for the new image
                $sguid = dirname($post->guid) . "/" . basename($data['file']);
                $ewww_debug .= "new guid: {$sguid} <br>";
                // retrieve any posts that link the resize
                $ersql = $wpdb->prepare("SELECT ID, post_content FROM {$wpdb->posts} WHERE post_content LIKE '%%%s%%'", $old_sguid);
                $ewww_debug .= "using query: {$ersql}<br>";
                $rows = $wpdb->get_results($ersql, ARRAY_A);
                // while there are posts to process
                foreach ($rows as $row) {
                    // replace all occurences of the old guid with the new guid
                    $post_content = str_replace($old_sguid, $sguid, $row['post_content']);
                    $ewww_debug .= "replacing {$old_sguid} with {$sguid} in post " . $row['ID'] . '<br>';
                    // send the updated content back to the database
                    $wpdb->update($wpdb->posts, array('post_content' => $post_content), array('ID' => $row['ID']));
                }
            }
        }
    }
    // if the new image is a JPG
    if (preg_match('/.jpg$/i', basename($meta['file']))) {
        // set the mimetype to JPG
        $mime = 'image/jpg';
    }
    // if the new image is a PNG
    if (preg_match('/.png$/i', basename($meta['file']))) {
        // set the mimetype to PNG
        $mime = 'image/png';
    }
    if (preg_match('/.gif$/i', basename($meta['file']))) {
        // set the mimetype to GIF
        $mime = 'image/gif';
    }
    // update the attachment post with the new mimetype and guid
    wp_update_post(array('ID' => $ID, 'post_mime_type' => $mime, 'guid' => $guid));
    ewww_image_optimizer_debug_log();
    ewwwio_memory(__FUNCTION__);
    return $meta;
}
开发者ID:goodbayscott,项目名称:wwr-temp,代码行数:79,代码来源:common.php

示例7: _save

 protected function _save($image, $filename = null, $mime_type = null)
 {
     global $ewww_debug;
     if (!defined('EWWW_IMAGE_OPTIMIZER_DOMAIN')) {
         require_once plugin_dir_path(__FILE__) . 'ewww-image-optimizer.php';
     }
     if (!defined('EWWW_IMAGE_OPTIMIZER_JPEGTRAN')) {
         ewww_image_optimizer_init();
     }
     list($filename, $extension, $mime_type) = $this->get_output_format($filename, $mime_type);
     if (!$filename) {
         $filename = $this->generate_filename(null, null, $extension);
     }
     try {
         // Store initial Format
         $orig_format = $this->image->getimageformat();
         $this->image->setimageformat(strtoupper($this->get_extension($mime_type)));
         $this->make_image($filename, array($image, 'writeImage'), array($filename));
         // Reset original Format
         $this->image->setimageformat($orig_format);
     } catch (Exception $e) {
         return new WP_Error('image_save_error', $e->getMessage(), $filename);
     }
     // Set correct file permissions
     $stat = stat(dirname($filename));
     $perms = $stat['mode'] & 0666;
     //same permissions as parent folder, strip off the executable bits
     @chmod($filename, $perms);
     ewww_image_optimizer_aux_images_loop($filename, true);
     $ewww_debug = "{$ewww_debug} image editor (gmagick) saved : {$filename} <br>";
     $image_size = filesize($filename);
     $ewww_debug = "{$ewww_debug} image editor size: {$image_size} <br>";
     ewww_image_optimizer_debug_log();
     $ewww_debug = '';
     return array('path' => $filename, 'file' => wp_basename(apply_filters('image_make_intermediate_size', $filename)), 'width' => $this->size['width'], 'height' => $this->size['height'], 'mime-type' => $mime_type);
 }
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:36,代码来源:image-editor.php

示例8: ewww_image_optimizer_aux_images_script

function ewww_image_optimizer_aux_images_script($hook)
{
    // make sure we are being called from the proper page
    if ('ewww-image-optimizer-auto' !== $hook && empty($_REQUEST['scan'])) {
        return;
    }
    global $ewww_debug;
    global $wpdb;
    $ewww_debug .= "<b>ewww_image_optimizer_aux_images_script()</b><br>";
    // initialize the $attachments variable for auxiliary images
    $attachments = null;
    // check the 'bulk resume' option
    $resume = get_option('ewww_image_optimizer_aux_resume');
    // check if there is a previous bulk operation to resume
    if (!empty($resume)) {
        // retrieve the attachment IDs that have not been finished from the 'bulk attachments' option
        $attachments = get_option('ewww_image_optimizer_aux_attachments');
    } else {
        // collect a list of images from the current theme
        $child_path = get_stylesheet_directory();
        $parent_path = get_template_directory();
        $attachments = ewww_image_optimizer_image_scan($child_path);
        if ($child_path !== $parent_path) {
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($parent_path));
        }
        // collect a list of images in auxiliary folders provided by user
        if ($aux_paths = ewww_image_optimizer_get_option('ewww_image_optimizer_aux_paths')) {
            foreach ($aux_paths as $aux_path) {
                $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($aux_path));
            }
        }
        // collect a list of images for buddypress
        if (is_plugin_active('buddypress/bp-loader.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('buddypress/bp-loader.php')) {
            // get the value of the wordpress upload directory
            $upload_dir = wp_upload_dir();
            // scan the 'avatars' and 'group-avatars' folders for images
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($upload_dir['basedir'] . '/avatars'), ewww_image_optimizer_image_scan($upload_dir['basedir'] . '/group-avatars'));
        }
        if (is_plugin_active('buddypress-activity-plus/bpfb.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('buddypress-activity-plus/bpfb.php')) {
            // get the value of the wordpress upload directory
            $upload_dir = wp_upload_dir();
            // scan the 'avatars' and 'group-avatars' folders for images
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($upload_dir['basedir'] . '/bpfb'));
        }
        if (is_plugin_active('wp-symposium/wp-symposium.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('wp-symposium/wp-symposium.php')) {
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan(get_option('symposium_img_path')));
        }
        if (is_plugin_active('ml-slider/ml-slider.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('ml-slider/ml-slider.php')) {
            $slide_paths = array();
            $sliders = get_posts(array('numberposts' => -1, 'post_type' => 'ml-slider', 'post_status' => 'any', 'fields' => 'ids'));
            foreach ($sliders as $slider) {
                $slides = get_posts(array('numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_status' => 'inherit', 'fields' => 'ids', 'tax_query' => array(array('taxonomy' => 'ml-slider', 'field' => 'slug', 'terms' => $slider))));
                foreach ($slides as $slide) {
                    $backup_sizes = get_post_meta($slide, '_wp_attachment_backup_sizes', true);
                    $type = get_post_meta($slide, 'ml-slider_type', true);
                    $type = $type ? $type : 'image';
                    // backwards compatibility, fall back to 'image'
                    if ($type === 'image') {
                        foreach ($backup_sizes as $backup_size => $meta) {
                            if (preg_match('/resized-/', $backup_size)) {
                                $path = $meta['path'];
                                $image_size = filesize($path);
                                $query = $wpdb->prepare("SELECT id FROM {$wpdb->ewwwio_images} WHERE BINARY path LIKE %s AND image_size LIKE '{$image_size}'", $path);
                                $already_optimized = $wpdb->get_results($query);
                                $mimetype = ewww_image_optimizer_mimetype($path, 'i');
                                if (preg_match('/^image\\/(jpeg|png|gif)/', $mimetype) && empty($already_optimized)) {
                                    $slide_paths[] = $path;
                                }
                            }
                        }
                    }
                }
            }
            $attachments = array_merge($attachments, $slide_paths);
        }
        // store the filenames we retrieved in the 'bulk_attachments' option so we can keep track of our progress in the database
        update_option('ewww_image_optimizer_aux_attachments', $attachments);
    }
    ewww_image_optimizer_debug_log();
    // submit a couple variables to the javascript to work with
    $attachments = json_encode($attachments);
    if (!empty($_REQUEST['scan'])) {
        if (empty($attachments)) {
            _e('Nothing to optimize', EWWW_IMAGE_OPTIMIZER_DOMAIN);
        } else {
            echo $attachments;
        }
        die;
    } else {
        return;
    }
}
开发者ID:LacieNat,项目名称:Access-Comm-Project,代码行数:92,代码来源:aux-optimize.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_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:Rudchyk,项目名称:wp-framework,代码行数:19,代码来源:nextgen2-integration.php

示例10: ewww_image_optimizer_aux_images_script


//.........这里部分代码省略.........
        // retrieve the attachment IDs that have not been finished from the 'bulk attachments' option
        $attachments = get_option('ewww_image_optimizer_aux_attachments');
    } else {
        ewwwio_debug_message('getting fresh list of files to optimize');
        $attachments = array();
        // collect a list of images from the current theme
        $child_path = get_stylesheet_directory();
        $parent_path = get_template_directory();
        $attachments = ewww_image_optimizer_image_scan($child_path);
        if ($child_path !== $parent_path) {
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($parent_path));
        }
        if (!function_exists('is_plugin_active')) {
            // need to include the plugin library for the is_plugin_active function
            require_once ABSPATH . 'wp-admin/includes/plugin.php';
        }
        // collect a list of images for buddypress
        if (is_plugin_active('buddypress/bp-loader.php') || is_plugin_active_for_network('buddypress/bp-loader.php')) {
            // get the value of the wordpress upload directory
            $upload_dir = wp_upload_dir();
            // scan the 'avatars' and 'group-avatars' folders for images
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($upload_dir['basedir'] . '/avatars'), ewww_image_optimizer_image_scan($upload_dir['basedir'] . '/group-avatars'));
        }
        if (is_plugin_active('buddypress-activity-plus/bpfb.php') || is_plugin_active_for_network('buddypress-activity-plus/bpfb.php')) {
            // get the value of the wordpress upload directory
            $upload_dir = wp_upload_dir();
            // scan the 'avatars' and 'group-avatars' folders for images
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($upload_dir['basedir'] . '/bpfb'));
        }
        if (is_plugin_active('grand-media/grand-media.php') || is_plugin_active_for_network('grand-media/grand-media.php')) {
            // scan the grand media folder for images
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan(WP_CONTENT_DIR . '/grand-media'));
        }
        if (is_plugin_active('wp-symposium/wp-symposium.php') || is_plugin_active_for_network('wp-symposium/wp-symposium.php')) {
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan(get_option('symposium_img_path')));
        }
        if (is_plugin_active('ml-slider/ml-slider.php') || is_plugin_active_for_network('ml-slider/ml-slider.php')) {
            $slide_paths = array();
            $slides = $wpdb->get_col("\n\t\t\t\tSELECT wpposts.ID \n\t\t\t\tFROM {$wpdb->posts} wpposts \n\t\t\t\tINNER JOIN {$wpdb->term_relationships} term_relationships\n\t\t\t\t\t\tON wpposts.ID = term_relationships.object_id\n\t\t\t\tINNER JOIN {$wpdb->terms} wpterms \n\t\t\t\t\t\tON term_relationships.term_taxonomy_id = wpterms.term_id\n\t\t\t\tINNER JOIN {$wpdb->term_taxonomy} term_taxonomy\n\t\t\t\t\t\tON wpterms.term_id = term_taxonomy.term_id\n\t\t\t\tWHERE \tterm_taxonomy.taxonomy = 'ml-slider'\n\t\t\t\t\tAND wpposts.post_type = 'attachment'\n\t\t\t\t");
            foreach ($slides as $slide) {
                $backup_sizes = get_post_meta($slide, '_wp_attachment_backup_sizes', true);
                $type = get_post_meta($slide, 'ml-slider_type', true);
                $type = $type ? $type : 'image';
                // backwards compatibility, fall back to 'image'
                if ($type === 'image') {
                    foreach ($backup_sizes as $backup_size => $meta) {
                        if (preg_match('/resized-/', $backup_size)) {
                            $path = $meta['path'];
                            $image_size = ewww_image_optimizer_filesize($path);
                            if (!$image_size) {
                                continue;
                            }
                            $already_optimized = ewww_image_optimizer_find_already_optimized($path);
                            $mimetype = ewww_image_optimizer_mimetype($path, 'i');
                            if (preg_match('/^image\\/(jpeg|png|gif)/', $mimetype) && empty($already_optimized)) {
                                $slide_paths[] = $path;
                            }
                        }
                    }
                }
            }
            $attachments = array_merge($attachments, $slide_paths);
        }
        // collect a list of images in auxiliary folders provided by user
        if ($aux_paths = ewww_image_optimizer_get_option('ewww_image_optimizer_aux_paths')) {
            foreach ($aux_paths as $aux_path) {
                $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($aux_path));
            }
        }
        // scan images in two most recent media library folders if the option is enabled, and this is a scheduled optimization
        if ('ewww-image-optimizer-auto' == $hook && ewww_image_optimizer_get_option('ewww_image_optimizer_include_media_paths')) {
            // retrieve the location of the wordpress upload folder
            $upload_dir = wp_upload_dir();
            // retrieve the path of the upload folder
            $upload_path = $upload_dir['basedir'];
            $this_month = date('m');
            $this_year = date('Y');
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan("{$upload_path}/{$this_year}/{$this_month}/"));
            if (class_exists('DateTime')) {
                $date = new DateTime();
                $date->sub(new DateInterval('P1M'));
                $last_year = $date->format('Y');
                $last_month = $date->format('m');
                $attachments = array_merge($attachments, ewww_image_optimizer_image_scan("{$upload_path}/{$last_year}/{$last_month}/"));
            }
        }
        // store the filenames we retrieved in the 'bulk_attachments' option so we can keep track of our progress in the database
        update_option('ewww_image_optimizer_aux_attachments', $attachments);
        ewwwio_debug_message('found ' . count($attachments) . ' images to optimize while scanning');
    }
    ewww_image_optimizer_debug_log();
    if (!empty($_REQUEST['ewww_scan'])) {
        echo count($attachments);
        ewwwio_memory(__FUNCTION__);
        die;
    } else {
        ewwwio_memory(__FUNCTION__);
        return;
    }
}
开发者ID:kanei,项目名称:vantuch.cz,代码行数:101,代码来源:aux-optimize.php

示例11: ewww_image_optimizer_webp_loop

function ewww_image_optimizer_webp_loop()
{
    ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
    $permissions = apply_filters('ewww_image_optimizer_admin_permissions', '');
    if (!wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-webp') || !current_user_can($permissions)) {
        wp_die(esc_html__('Access token has expired, please reload the page.', EWWW_IMAGE_OPTIMIZER_DOMAIN));
    }
    // retrieve the time when the migration starts
    $started = microtime(true);
    // allow 50 seconds for each loop
    set_time_limit(50);
    $images = array();
    ewwwio_debug_message('renaming images now');
    $images_processed = 0;
    $images_skipped = '';
    $images = get_option('ewww_image_optimizer_webp_images');
    if ($images) {
        printf(esc_html__('%d Webp images left to rename.', EWWW_IMAGE_OPTIMIZER_DOMAIN), count($images));
        echo "<br>";
    }
    while ($images) {
        $images_processed++;
        ewwwio_debug_message("processed {$images_processed} images so far");
        if ($images_processed > 1000) {
            ewwwio_debug_message('hit 1000, breaking loop');
            break;
        }
        $image = array_pop($images);
        $replace_base = '';
        $skip = true;
        $pngfile = preg_replace('/webp$/', 'png', $image);
        $PNGfile = preg_replace('/webp$/', 'PNG', $image);
        $jpgfile = preg_replace('/webp$/', 'jpg', $image);
        $jpegfile = preg_replace('/webp$/', 'jpeg', $image);
        $JPGfile = preg_replace('/webp$/', 'JPG', $image);
        if (file_exists($pngfile)) {
            $replace_base = $pngfile;
            $skip = false;
        }
        if (file_exists($PNGfile)) {
            if (empty($replace_base)) {
                $replace_base = $PNGfile;
                $skip = false;
            } else {
                $skip = true;
            }
        }
        if (file_exists($jpgfile)) {
            if (empty($replace_base)) {
                $replace_base = $jpgfile;
                $skip = false;
            } else {
                $skip = true;
            }
        }
        if (file_exists($jpegfile)) {
            if (empty($replace_base)) {
                $replace_base = $jpegfile;
                $skip = false;
            } else {
                $skip = true;
            }
        }
        if (file_exists($JPGfile)) {
            if (empty($replace_base)) {
                $replace_base = $JPGfile;
                $skip = false;
            } else {
                $skip = true;
            }
        }
        if ($skip) {
            if ($replace_base) {
                ewwwio_debug_message("multiple replacement options for {$image}, not renaming");
            } else {
                ewwwio_debug_message("no match found for {$image}, strange...");
            }
            $images_skipped .= "{$image}<br>";
        } else {
            ewwwio_debug_message("renaming {$image} with match of {$replace_base}");
            rename($image, $replace_base . '.webp');
        }
    }
    if ($images_skipped) {
        update_option('ewww_image_optimizer_webp_skipped', get_option('ewww_image_optimizer_webp_skipped') . $images_skipped);
    }
    // calculate how much time has elapsed since we started
    $elapsed = microtime(true) - $started;
    ewwwio_debug_message("took {$elapsed} seconds this time around");
    // store the updated list of images back in the database
    update_option('ewww_image_optimizer_webp_images', $images);
    ewww_image_optimizer_debug_log();
    die;
}
开发者ID:agiper,项目名称:wordpress,代码行数:94,代码来源:mwebp.php

示例12: ewww_image_optimizer_aux_images_script


//.........这里部分代码省略.........
        }
        // collect a list of images for buddypress
        if (is_plugin_active('buddypress/bp-loader.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('buddypress/bp-loader.php')) {
            // get the value of the wordpress upload directory
            $upload_dir = wp_upload_dir();
            // scan the 'avatars' and 'group-avatars' folders for images
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($upload_dir['basedir'] . '/avatars'), ewww_image_optimizer_image_scan($upload_dir['basedir'] . '/group-avatars'));
        }
        if (is_plugin_active('buddypress-activity-plus/bpfb.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('buddypress-activity-plus/bpfb.php')) {
            // get the value of the wordpress upload directory
            $upload_dir = wp_upload_dir();
            // scan the 'avatars' and 'group-avatars' folders for images
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($upload_dir['basedir'] . '/bpfb'));
        }
        if (is_plugin_active('grand-media/grand-media.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('grand-media/grand-media.php')) {
            // scan the grand media folder for images
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan(WP_CONTENT_DIR . '/grand-media'));
        }
        if (is_plugin_active('wp-symposium/wp-symposium.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('wp-symposium/wp-symposium.php')) {
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan(get_option('symposium_img_path')));
        }
        if (is_plugin_active('ml-slider/ml-slider.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('ml-slider/ml-slider.php')) {
            $slide_paths = array();
            $sliders = get_posts(array('numberposts' => -1, 'post_type' => 'ml-slider', 'post_status' => 'any', 'fields' => 'ids'));
            foreach ($sliders as $slider) {
                $slides = get_posts(array('numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_status' => 'inherit', 'fields' => 'ids', 'tax_query' => array(array('taxonomy' => 'ml-slider', 'field' => 'slug', 'terms' => $slider))));
                foreach ($slides as $slide) {
                    $backup_sizes = get_post_meta($slide, '_wp_attachment_backup_sizes', true);
                    $type = get_post_meta($slide, 'ml-slider_type', true);
                    $type = $type ? $type : 'image';
                    // backwards compatibility, fall back to 'image'
                    if ($type === 'image') {
                        foreach ($backup_sizes as $backup_size => $meta) {
                            if (preg_match('/resized-/', $backup_size)) {
                                $path = $meta['path'];
                                $image_size = filesize($path);
                                $query = $wpdb->prepare("SELECT id FROM {$wpdb->ewwwio_images} WHERE path LIKE %s AND image_size LIKE '{$image_size}'", $path);
                                $optimized_query = $wpdb->get_results($query, ARRAY_A);
                                if (!empty($optimized_query)) {
                                    foreach ($optimized_query as $image) {
                                        if ($image['path'] != $path) {
                                            $ewww_debug .= "{$image['path']} does not match {$path}, continuing our search<br>";
                                        } else {
                                            $already_optimized = $image;
                                        }
                                    }
                                }
                                $mimetype = ewww_image_optimizer_mimetype($path, 'i');
                                if (preg_match('/^image\\/(jpeg|png|gif)/', $mimetype) && empty($already_optimized)) {
                                    $slide_paths[] = $path;
                                }
                            }
                        }
                    }
                }
            }
            $attachments = array_merge($attachments, $slide_paths);
        }
        // collect a list of images in auxiliary folders provided by user
        if ($aux_paths = ewww_image_optimizer_get_option('ewww_image_optimizer_aux_paths')) {
            foreach ($aux_paths as $aux_path) {
                $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($aux_path));
            }
        }
        // scan images in two most recent media library folders if the option is enabled, and this is a scheduled optimization
        if ('ewww-image-optimizer-auto' == $hook && ewww_image_optimizer_get_option('ewww_image_optimizer_include_media_paths')) {
            // retrieve the location of the wordpress upload folder
            $upload_dir = wp_upload_dir();
            // retrieve the path of the upload folder
            $upload_path = $upload_dir['basedir'];
            $this_month = date('m');
            $this_year = date('Y');
            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan("{$upload_path}/{$this_year}/{$this_month}/"));
            if (class_exists('DateTime')) {
                $date = new DateTime();
                $date->sub(new DateInterval('P1M'));
                $last_year = $date->format('Y');
                $last_month = $date->format('m');
                $attachments = array_merge($attachments, ewww_image_optimizer_image_scan("{$upload_path}/{$last_year}/{$last_month}/"));
            }
        }
        // store the filenames we retrieved in the 'bulk_attachments' option so we can keep track of our progress in the database
        update_option('ewww_image_optimizer_aux_attachments', $attachments);
    }
    ewww_image_optimizer_debug_log();
    // submit a couple variables to the javascript to work with
    $attachments = json_encode($attachments);
    if (!empty($_REQUEST['ewww_scan'])) {
        if (empty($attachments)) {
            _e('Nothing to optimize', EWWW_IMAGE_OPTIMIZER_DOMAIN);
        } else {
            echo $attachments;
        }
        ewwwio_memory(__FUNCTION__);
        die;
    } else {
        ewwwio_memory(__FUNCTION__);
        return;
    }
}
开发者ID:jrald1291,项目名称:atu,代码行数:101,代码来源:aux-optimize.php

示例13: cancel_process

 /**
  * Cancel Process
  *
  * Stop processing queue items, clear cronjob and delete batch.
  *
  */
 public function cancel_process()
 {
     ewwwio_debug_message('cancelling background process');
     if (!$this->is_queue_empty()) {
         $batch = $this->get_batch();
         ewwwio_debug_message('retrieved key ' . $batch->key);
         $this->delete($batch->key);
         wp_clear_scheduled_hook($this->cron_hook_identifier);
     }
     ewww_image_optimizer_debug_log();
 }
开发者ID:crazyyy,项目名称:bessarabia,代码行数:17,代码来源:wp-background-process.php

示例14: ewww_image_optimizer_savings_loop

function ewww_image_optimizer_savings_loop()
{
    // verify that an authorized user has started the optimizer
    if (!wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-settings')) {
        wp_die(__('Cheatin&#8217; eh?', EWWW_IMAGE_OPTIMIZER_DOMAIN));
    }
    global $ewww_debug;
    global $wpdb;
    if ($_REQUEST['ewww_savings_todo'] < 1000) {
        $records_needed = $_REQUEST['ewww_savings_todo'];
    } else {
        $records_needed = 1000;
    }
    if (function_exists('is_plugin_active_for_network') && is_plugin_active_for_network(EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL)) {
        if (function_exists('wp_get_sites')) {
            add_filter('wp_is_large_network', 'ewww_image_optimizer_large_network', 20, 0);
            $blogs = wp_get_sites(array('network_id' => $wpdb->siteid, 'limit' => 10000));
            remove_filter('wp_is_large_network', 'ewww_image_optimizer_large_network', 20, 0);
        } else {
            $query = "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
            $blogs = $wpdb->get_results($query, ARRAY_A);
        }
        $total_savings = 0;
        $savings_done = $_REQUEST['ewww_savings_counter'];
        foreach ($blogs as $blog) {
            switch_to_blog($blog['blog_id']);
            $total_query = "SELECT orig_size-image_size FROM {$wpdb->ewwwio_images} LIMIT {$_REQUEST['ewww_savings_counter']}, {$records_needed}";
            $ewww_debug .= "querying {$records_needed} records, starting at {$_REQUEST['ewww_savings_counter']}<br>";
            $savings = $wpdb->get_results($total_query, ARRAY_N);
            $records_needed -= count($savings);
            foreach ($savings as $saved) {
                $total_savings += $saved[0];
            }
            if ($records_needed) {
                $savings_done -= $wpdb->get_var("SELECT COUNT(id) FROM {$wpdb->ewwwio_images}");
            } else {
                break;
            }
        }
        restore_current_blog();
    } else {
        $total_query = "SELECT orig_size-image_size FROM {$wpdb->ewwwio_images} LIMIT {$_REQUEST['ewww_savings_counter']}, {$records_needed}";
        $ewww_debug .= "querying {$records_needed} records, starting at {$_REQUEST['ewww_savings_counter']}<br>";
        $savings = $wpdb->get_results($total_query, ARRAY_N);
        $total_savings = 0;
        foreach ($savings as $saved) {
            $total_savings += $saved[0];
        }
    }
    ewww_image_optimizer_debug_log();
    echo $total_savings;
    ewwwio_memory(__FUNCTION__);
    die;
}
开发者ID:hkarriche,项目名称:wordpress,代码行数:54,代码来源:common.php

示例15: ewww_added_new_image_slow

 function ewww_added_new_image_slow($image)
 {
     ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
     // make sure the image path is set
     if (isset($image->imagePath)) {
         // 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);
         if (!class_exists('flagMeta')) {
             require_once FLAG_ABSPATH . 'lib/meta.php';
         }
         // retrieve the metadata for the image ID
         $pid = $image->pid;
         $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:ChrisSargent,项目名称:moodesignz,代码行数:28,代码来源:flag-integration.php


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