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


PHP ewww_image_optimizer_init函数代码示例

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


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

示例1: ewww_image_optimizer_admin_init

function ewww_image_optimizer_admin_init()
{
    ewwwio_memory(__FUNCTION__);
    global $ewww_debug;
    $ewww_debug .= "<b>ewww_image_optimizer_admin_init()</b><br>";
    ewww_image_optimizer_init();
    if (function_exists('is_plugin_active_for_network') && is_plugin_active_for_network(EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL)) {
        // set the common network settings if they have been POSTed
        if (isset($_POST['ewww_image_optimizer_delay']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'ewww_image_optimizer_options-options')) {
            if (empty($_POST['ewww_image_optimizer_debug'])) {
                $_POST['ewww_image_optimizer_debug'] = '';
            }
            update_site_option('ewww_image_optimizer_debug', $_POST['ewww_image_optimizer_debug']);
            if (empty($_POST['ewww_image_optimizer_jpegtran_copy'])) {
                $_POST['ewww_image_optimizer_jpegtran_copy'] = '';
            }
            update_site_option('ewww_image_optimizer_jpegtran_copy', $_POST['ewww_image_optimizer_jpegtran_copy']);
            if (empty($_POST['ewww_image_optimizer_jpg_lossy'])) {
                $_POST['ewww_image_optimizer_jpg_lossy'] = '';
            }
            update_site_option('ewww_image_optimizer_jpg_lossy', $_POST['ewww_image_optimizer_jpg_lossy']);
            if (empty($_POST['ewww_image_optimizer_png_lossy'])) {
                $_POST['ewww_image_optimizer_png_lossy'] = '';
            }
            update_site_option('ewww_image_optimizer_png_lossy', $_POST['ewww_image_optimizer_png_lossy']);
            if (empty($_POST['ewww_image_optimizer_lossy_fast'])) {
                $_POST['ewww_image_optimizer_lossy_fast'] = '';
            }
            update_site_option('ewww_image_optimizer_lossy_fast', $_POST['ewww_image_optimizer_lossy_fast']);
            if (empty($_POST['ewww_image_optimizer_lossy_skip_full'])) {
                $_POST['ewww_image_optimizer_lossy_skip_full'] = '';
            }
            update_site_option('ewww_image_optimizer_lossy_skip_full', $_POST['ewww_image_optimizer_lossy_skip_full']);
            if (empty($_POST['ewww_image_optimizer_metadata_skip_full'])) {
                $_POST['ewww_image_optimizer_metadata_skip_full'] = '';
            }
            update_site_option('ewww_image_optimizer_metadata_skip_full', $_POST['ewww_image_optimizer_metadata_skip_full']);
            if (empty($_POST['ewww_image_optimizer_delete_originals'])) {
                $_POST['ewww_image_optimizer_delete_originals'] = '';
            }
            update_site_option('ewww_image_optimizer_delete_originals', $_POST['ewww_image_optimizer_delete_originals']);
            if (empty($_POST['ewww_image_optimizer_jpg_to_png'])) {
                $_POST['ewww_image_optimizer_jpg_to_png'] = '';
            }
            update_site_option('ewww_image_optimizer_jpg_to_png', $_POST['ewww_image_optimizer_jpg_to_png']);
            if (empty($_POST['ewww_image_optimizer_png_to_jpg'])) {
                $_POST['ewww_image_optimizer_png_to_jpg'] = '';
            }
            update_site_option('ewww_image_optimizer_png_to_jpg', $_POST['ewww_image_optimizer_png_to_jpg']);
            if (empty($_POST['ewww_image_optimizer_gif_to_png'])) {
                $_POST['ewww_image_optimizer_gif_to_png'] = '';
            }
            update_site_option('ewww_image_optimizer_gif_to_png', $_POST['ewww_image_optimizer_gif_to_png']);
            if (empty($_POST['ewww_image_optimizer_webp'])) {
                $_POST['ewww_image_optimizer_webp'] = '';
            }
            update_site_option('ewww_image_optimizer_webp', $_POST['ewww_image_optimizer_webp']);
            if (empty($_POST['ewww_image_optimizer_jpg_background'])) {
                $_POST['ewww_image_optimizer_jpg_background'] = '';
            }
            update_site_option('ewww_image_optimizer_jpg_background', ewww_image_optimizer_jpg_background($_POST['ewww_image_optimizer_jpg_background']));
            if (empty($_POST['ewww_image_optimizer_jpg_quality'])) {
                $_POST['ewww_image_optimizer_jpg_quality'] = '';
            }
            update_site_option('ewww_image_optimizer_jpg_quality', ewww_image_optimizer_jpg_quality($_POST['ewww_image_optimizer_jpg_quality']));
            if (empty($_POST['ewww_image_optimizer_disable_convert_links'])) {
                $_POST['ewww_image_optimizer_disable_convert_links'] = '';
            }
            update_site_option('ewww_image_optimizer_disable_convert_links', $_POST['ewww_image_optimizer_disable_convert_links']);
            if (empty($_POST['ewww_image_optimizer_cloud_key'])) {
                $_POST['ewww_image_optimizer_cloud_key'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_key', ewww_image_optimizer_cloud_key_sanitize($_POST['ewww_image_optimizer_cloud_key']));
            if (empty($_POST['ewww_image_optimizer_cloud_jpg'])) {
                $_POST['ewww_image_optimizer_cloud_jpg'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_jpg', $_POST['ewww_image_optimizer_cloud_jpg']);
            if (empty($_POST['ewww_image_optimizer_cloud_png'])) {
                $_POST['ewww_image_optimizer_cloud_png'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_png', $_POST['ewww_image_optimizer_cloud_png']);
            if (empty($_POST['ewww_image_optimizer_cloud_png_compress'])) {
                $_POST['ewww_image_optimizer_cloud_png_compress'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_png_compress', $_POST['ewww_image_optimizer_cloud_png_compress']);
            if (empty($_POST['ewww_image_optimizer_cloud_gif'])) {
                $_POST['ewww_image_optimizer_cloud_gif'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_gif', $_POST['ewww_image_optimizer_cloud_gif']);
            if (empty($_POST['ewww_image_optimizer_auto'])) {
                $_POST['ewww_image_optimizer_auto'] = '';
            }
            update_site_option('ewww_image_optimizer_auto', $_POST['ewww_image_optimizer_auto']);
            if (empty($_POST['ewww_image_optimizer_aux_paths'])) {
                $_POST['ewww_image_optimizer_aux_paths'] = '';
            }
            update_site_option('ewww_image_optimizer_aux_paths', ewww_image_optimizer_aux_paths_sanitize($_POST['ewww_image_optimizer_aux_paths']));
            if (empty($_POST['ewww_image_optimizer_enable_cloudinary'])) {
                $_POST['ewww_image_optimizer_enable_cloudinary'] = '';
            }
//.........这里部分代码省略.........
开发者ID:goodbayscott,项目名称:wwr-temp,代码行数:101,代码来源:common.php

示例2: _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

示例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_admin_init

function ewww_image_optimizer_admin_init()
{
    ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
    ewwwio_memory(__FUNCTION__);
    ewww_image_optimizer_init();
    if (!function_exists('is_plugin_active_for_network') && is_multisite()) {
        // need to include the plugin library for the is_plugin_active function
        require_once ABSPATH . 'wp-admin/includes/plugin.php';
    }
    if (is_multisite() && is_plugin_active_for_network(EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL)) {
        // set the common network settings if they have been POSTed
        if (isset($_POST['ewww_image_optimizer_delay']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'ewww_image_optimizer_options-options')) {
            if (empty($_POST['ewww_image_optimizer_debug'])) {
                $_POST['ewww_image_optimizer_debug'] = '';
            }
            update_site_option('ewww_image_optimizer_debug', $_POST['ewww_image_optimizer_debug']);
            if (empty($_POST['ewww_image_optimizer_jpegtran_copy'])) {
                $_POST['ewww_image_optimizer_jpegtran_copy'] = '';
            }
            update_site_option('ewww_image_optimizer_jpegtran_copy', $_POST['ewww_image_optimizer_jpegtran_copy']);
            if (empty($_POST['ewww_image_optimizer_jpg_lossy'])) {
                $_POST['ewww_image_optimizer_jpg_lossy'] = '';
            }
            update_site_option('ewww_image_optimizer_jpg_lossy', $_POST['ewww_image_optimizer_jpg_lossy']);
            if (empty($_POST['ewww_image_optimizer_png_lossy'])) {
                $_POST['ewww_image_optimizer_png_lossy'] = '';
            }
            update_site_option('ewww_image_optimizer_png_lossy', $_POST['ewww_image_optimizer_png_lossy']);
            if (empty($_POST['ewww_image_optimizer_lossy_fast'])) {
                $_POST['ewww_image_optimizer_lossy_fast'] = '';
            }
            update_site_option('ewww_image_optimizer_lossy_fast', $_POST['ewww_image_optimizer_lossy_fast']);
            if (empty($_POST['ewww_image_optimizer_lossy_skip_full'])) {
                $_POST['ewww_image_optimizer_lossy_skip_full'] = '';
            }
            update_site_option('ewww_image_optimizer_lossy_skip_full', $_POST['ewww_image_optimizer_lossy_skip_full']);
            if (empty($_POST['ewww_image_optimizer_metadata_skip_full'])) {
                $_POST['ewww_image_optimizer_metadata_skip_full'] = '';
            }
            update_site_option('ewww_image_optimizer_metadata_skip_full', $_POST['ewww_image_optimizer_metadata_skip_full']);
            if (empty($_POST['ewww_image_optimizer_delete_originals'])) {
                $_POST['ewww_image_optimizer_delete_originals'] = '';
            }
            update_site_option('ewww_image_optimizer_delete_originals', $_POST['ewww_image_optimizer_delete_originals']);
            if (empty($_POST['ewww_image_optimizer_jpg_to_png'])) {
                $_POST['ewww_image_optimizer_jpg_to_png'] = '';
            }
            update_site_option('ewww_image_optimizer_jpg_to_png', $_POST['ewww_image_optimizer_jpg_to_png']);
            if (empty($_POST['ewww_image_optimizer_png_to_jpg'])) {
                $_POST['ewww_image_optimizer_png_to_jpg'] = '';
            }
            update_site_option('ewww_image_optimizer_png_to_jpg', $_POST['ewww_image_optimizer_png_to_jpg']);
            if (empty($_POST['ewww_image_optimizer_gif_to_png'])) {
                $_POST['ewww_image_optimizer_gif_to_png'] = '';
            }
            update_site_option('ewww_image_optimizer_gif_to_png', $_POST['ewww_image_optimizer_gif_to_png']);
            if (empty($_POST['ewww_image_optimizer_webp'])) {
                $_POST['ewww_image_optimizer_webp'] = '';
            }
            update_site_option('ewww_image_optimizer_webp', $_POST['ewww_image_optimizer_webp']);
            if (empty($_POST['ewww_image_optimizer_jpg_background'])) {
                $_POST['ewww_image_optimizer_jpg_background'] = '';
            }
            update_site_option('ewww_image_optimizer_jpg_background', ewww_image_optimizer_jpg_background($_POST['ewww_image_optimizer_jpg_background']));
            if (empty($_POST['ewww_image_optimizer_jpg_quality'])) {
                $_POST['ewww_image_optimizer_jpg_quality'] = '';
            }
            update_site_option('ewww_image_optimizer_jpg_quality', ewww_image_optimizer_jpg_quality($_POST['ewww_image_optimizer_jpg_quality']));
            if (empty($_POST['ewww_image_optimizer_disable_convert_links'])) {
                $_POST['ewww_image_optimizer_disable_convert_links'] = '';
            }
            update_site_option('ewww_image_optimizer_disable_convert_links', $_POST['ewww_image_optimizer_disable_convert_links']);
            if (empty($_POST['ewww_image_optimizer_cloud_key'])) {
                $_POST['ewww_image_optimizer_cloud_key'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_key', ewww_image_optimizer_cloud_key_sanitize($_POST['ewww_image_optimizer_cloud_key']));
            if (empty($_POST['ewww_image_optimizer_cloud_jpg'])) {
                $_POST['ewww_image_optimizer_cloud_jpg'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_jpg', $_POST['ewww_image_optimizer_cloud_jpg']);
            if (empty($_POST['ewww_image_optimizer_cloud_png'])) {
                $_POST['ewww_image_optimizer_cloud_png'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_png', $_POST['ewww_image_optimizer_cloud_png']);
            if (empty($_POST['ewww_image_optimizer_cloud_png_compress'])) {
                $_POST['ewww_image_optimizer_cloud_png_compress'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_png_compress', $_POST['ewww_image_optimizer_cloud_png_compress']);
            if (empty($_POST['ewww_image_optimizer_cloud_gif'])) {
                $_POST['ewww_image_optimizer_cloud_gif'] = '';
            }
            update_site_option('ewww_image_optimizer_cloud_gif', $_POST['ewww_image_optimizer_cloud_gif']);
            if (empty($_POST['ewww_image_optimizer_auto'])) {
                $_POST['ewww_image_optimizer_auto'] = '';
            }
            update_site_option('ewww_image_optimizer_auto', $_POST['ewww_image_optimizer_auto']);
            if (empty($_POST['ewww_image_optimizer_aux_paths'])) {
                $_POST['ewww_image_optimizer_aux_paths'] = '';
            }
            update_site_option('ewww_image_optimizer_aux_paths', ewww_image_optimizer_aux_paths_sanitize($_POST['ewww_image_optimizer_aux_paths']));
//.........这里部分代码省略.........
开发者ID:amprog,项目名称:ewww-image-optimizer,代码行数:101,代码来源:common.php

示例5: ewww_image_optimizer

/**
 * Process an image.
 *
 * Returns an array of the $file, $results, $converted to tell us if an image changes formats, and the $original file if it did.
 *
 * @param   string $file		Full absolute path to the image file
 * @param   int $gallery_type		1=wordpress, 2=nextgen, 3=flagallery, 4=aux_images, 5=image editor, 6=imagestore, 7=retina
 * @param   boolean $converted		tells us if this is a resize and the full image was converted to a new format
 * @returns array
 */
function ewww_image_optimizer($file, $gallery_type, $converted, $new, $fullsize = false)
{
    //	global $wpdb;
    global $ewww_debug;
    $ewww_debug .= "<b>ewww_image_optimizer()</b><br>";
    // if the plugin gets here without initializing, we need to run through some things first
    if (!defined('EWWW_IMAGE_OPTIMIZER_CLOUD')) {
        ewww_image_optimizer_init();
    }
    // initialize the original filename
    $original = $file;
    $result = '';
    // check that the file exists
    if (FALSE === file_exists($file)) {
        // tell the user we couldn't find the file
        $msg = sprintf(__("Could not find <span class='code'>%s</span>", EWWW_IMAGE_OPTIMIZER_DOMAIN), $file);
        $ewww_debug .= "file doesn't appear to exist: {$file} <br>";
        // send back the above message
        return array(false, $msg, $converted, $original);
    }
    // check that the file is writable
    if (FALSE === is_writable($file)) {
        // tell the user we can't write to the file
        $msg = sprintf(__("<span class='code'>%s</span> is not writable", EWWW_IMAGE_OPTIMIZER_DOMAIN), $file);
        $ewww_debug .= "couldn't write to the file<br>";
        // send back the above message
        return array(false, $msg, $converted, $original);
    }
    if (function_exists('fileperms')) {
        $file_perms = substr(sprintf('%o', fileperms($file)), -4);
    }
    $file_owner = 'unknown';
    $file_group = 'unknown';
    if (function_exists('posix_getpwuid')) {
        $file_owner = posix_getpwuid(fileowner($file));
        $file_owner = $file_owner['name'];
    }
    if (function_exists('posix_getgrgid')) {
        $file_group = posix_getgrgid(filegroup($file));
        $file_group = $file_group['name'];
    }
    $ewww_debug .= "permissions: {$file_perms}, owner: {$file_owner}, group: {$file_group} <br>";
    $type = ewww_image_optimizer_mimetype($file, 'i');
    if (!$type) {
        //otherwise we store an error message since we couldn't get the mime-type
        $msg = __('Missing finfo_file(), getimagesize() and mime_content_type() PHP functions', EWWW_IMAGE_OPTIMIZER_DOMAIN);
        $ewww_debug .= "couldn't find any functions for mimetype detection<br>";
        return array(false, $msg, $converted, $original);
    }
    if (!EWWW_IMAGE_OPTIMIZER_CLOUD) {
        // check to see if 'nice' exists
        $nice = ewww_image_optimizer_find_binary('nice', 'n');
    }
    // if the user has disabled the utility checks
    if (ewww_image_optimizer_get_option('ewww_image_optimizer_skip_check') == TRUE || EWWW_IMAGE_OPTIMIZER_CLOUD) {
        $skip_jpegtran_check = true;
        $skip_optipng_check = true;
        $skip_gifsicle_check = true;
        $skip_pngout_check = true;
    } else {
        // otherwise we set the variables to false
        $skip_jpegtran_check = false;
        $skip_optipng_check = false;
        $skip_gifsicle_check = false;
        $skip_pngout_check = false;
    }
    if (ewww_image_optimizer_get_option('ewww_image_optimizer_cloud_jpg')) {
        $skip_jpegtran_check = true;
    }
    if (ewww_image_optimizer_get_option('ewww_image_optimizer_cloud_png')) {
        $skip_optipng_check = true;
        $skip_pngout_check = true;
    }
    if (ewww_image_optimizer_get_option('ewww_image_optimizer_cloud_gif')) {
        $skip_gifsicle_check = true;
    }
    // if the full-size image was converted
    if ($converted) {
        $ewww_debug .= "full-size image was converted, need to rebuild filename for meta<br>";
        $filenum = $converted;
        // grab the file extension
        preg_match('/\\.\\w+$/', $file, $fileext);
        // strip the file extension
        $filename = str_replace($fileext[0], '', $file);
        // grab the dimensions
        preg_match('/-\\d+x\\d+(-\\d+)*$/', $filename, $fileresize);
        // strip the dimensions
        $filename = str_replace($fileresize[0], '', $filename);
        // reconstruct the filename with the same increment (stored in $converted) as the full version
        $refile = $filename . '-' . $filenum . $fileresize[0] . $fileext[0];
//.........这里部分代码省略.........
开发者ID:LacieNat,项目名称:Access-Comm-Project,代码行数:101,代码来源:ewww-image-optimizer.php

示例6: ewww_image_optimizer

/**
 * Process an image.
 *
 * Returns an array of the $file, $results, $converted to tell us if an image changes formats, and the $original file if it did.
 *
 * @param   string $file		Full absolute path to the image file
 * @param   int $gallery_type		1=wordpress, 2=nextgen, 3=flagallery, 4=aux_images, 5=image editor, 6=imagestore, 7=retina
 * @param   boolean $converted		tells us if this is a resize and the full image was converted to a new format
 * @param   boolean $new		tells the optimizer that this is a new image, so it should attempt conversion regardless of previous results
 * @param   boolean $fullsize		tells the optimizer this is a full size image
 * @returns array
 */
function ewww_image_optimizer($file, $gallery_type = 4, $converted = false, $new = false, $fullsize = false)
{
    ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
    // if the plugin gets here without initializing, we need to run through some things first
    if (!defined('EWWW_IMAGE_OPTIMIZER_CLOUD')) {
        ewww_image_optimizer_init();
    }
    $bypass_optimization = apply_filters('ewww_image_optimizer_bypass', false, $file);
    if (true === $bypass_optimization) {
        // tell the user optimization was skipped
        $msg = __("Optimization skipped", EWWW_IMAGE_OPTIMIZER_DOMAIN);
        ewwwio_debug_message("optimization bypassed: {$file}");
        // send back the above message
        return array(false, $msg, $converted, $file);
    }
    // initialize the original filename
    $original = $file;
    $result = '';
    // check that the file exists
    if (FALSE === file_exists($file)) {
        // tell the user we couldn't find the file
        $msg = sprintf(__('Could not find %s', EWWW_IMAGE_OPTIMIZER_DOMAIN), $file);
        ewwwio_debug_message("file doesn't appear to exist: {$file}");
        // send back the above message
        return array(false, $msg, $converted, $original);
    }
    // check that the file is writable
    if (FALSE === is_writable($file)) {
        // tell the user we can't write to the file
        $msg = sprintf(__('%s is not writable', EWWW_IMAGE_OPTIMIZER_DOMAIN), $file);
        ewwwio_debug_message("couldn't write to the file {$file}");
        // send back the above message
        return array(false, $msg, $converted, $original);
    }
    if (function_exists('fileperms')) {
        $file_perms = substr(sprintf('%o', fileperms($file)), -4);
    }
    $file_owner = 'unknown';
    $file_group = 'unknown';
    if (function_exists('posix_getpwuid')) {
        $file_owner = posix_getpwuid(fileowner($file));
        $file_owner = $file_owner['name'];
    }
    if (function_exists('posix_getgrgid')) {
        $file_group = posix_getgrgid(filegroup($file));
        $file_group = $file_group['name'];
    }
    ewwwio_debug_message("permissions: {$file_perms}, owner: {$file_owner}, group: {$file_group}");
    $type = ewww_image_optimizer_mimetype($file, 'i');
    if (strpos($type, 'image') === FALSE) {
        ewwwio_debug_message('could not find any functions for mimetype detection');
        //otherwise we store an error message since we couldn't get the mime-type
        return array(false, __('Unknown type: ' . $type, EWWW_IMAGE_OPTIMIZER_DOMAIN), $converted, $original);
        $msg = __('Missing finfo_file(), getimagesize() and mime_content_type() PHP functions', EWWW_IMAGE_OPTIMIZER_DOMAIN);
        return array(false, $msg, $converted, $original);
    }
    if (!EWWW_IMAGE_OPTIMIZER_CLOUD) {
        // check to see if 'nice' exists
        $nice = ewww_image_optimizer_find_nix_binary('nice', 'n');
        if (!defined('EWWW_IMAGE_OPTIMIZER_NOEXEC')) {
            // Check if exec is disabled
            if (ewww_image_optimizer_exec_check()) {
                define('EWWW_IMAGE_OPTIMIZER_NOEXEC', true);
                ewwwio_debug_message('exec seems to be disabled');
                ewww_image_optimizer_disable_tools();
                // otherwise, query the php settings for safe mode
            } elseif (ewww_image_optimizer_safemode_check()) {
                define('EWWW_IMAGE_OPTIMIZER_NOEXEC', true);
                ewwwio_debug_message('safe mode appears to be enabled');
                ewww_image_optimizer_disable_tools();
            } else {
                define('EWWW_IMAGE_OPTIMIZER_NOEXEC', false);
            }
        }
    }
    // if the user has disabled the utility checks
    if (EWWW_IMAGE_OPTIMIZER_CLOUD) {
        $skip_jpegtran_check = true;
        $skip_optipng_check = true;
        $skip_gifsicle_check = true;
        $skip_pngout_check = true;
    } else {
        // otherwise we set the variables to false
        $skip_jpegtran_check = false;
        $skip_optipng_check = false;
        $skip_gifsicle_check = false;
        $skip_pngout_check = false;
    }
//.........这里部分代码省略.........
开发者ID:amprog,项目名称:ewww-image-optimizer,代码行数:101,代码来源:ewww-image-optimizer.php

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

示例8: ewww_image_optimizer_admin_init

function ewww_image_optimizer_admin_init() {
	ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
	ewwwio_memory( __FUNCTION__ );
	ewww_image_optimizer_init();
	if ( ! function_exists( 'is_plugin_active_for_network' ) && is_multisite() ) {
		// need to include the plugin library for the is_plugin_active function
		require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
	}
	if ( is_multisite() && is_plugin_active_for_network(EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
		// set the common network settings if they have been POSTed
		if ( isset( $_POST['ewww_image_optimizer_delay'] ) && current_user_can( 'manage_options' ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'ewww_image_optimizer_options-options' ) ) {
			ewwwio_debug_message( print_r( $_POST, true ) );
			$_POST['ewww_image_optimizer_debug'] = ( empty( $_POST['ewww_image_optimizer_debug'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_debug', $_POST['ewww_image_optimizer_debug'] );
			$_POST['ewww_image_optimizer_jpegtran_copy'] = ( empty( $_POST['ewww_image_optimizer_jpegtran_copy'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_jpegtran_copy', $_POST['ewww_image_optimizer_jpegtran_copy'] );
			if ( empty( $_POST['ewww_image_optimizer_jpg_level'] ) ) $_POST['ewww_image_optimizer_jpg_level'] = '';
			update_site_option( 'ewww_image_optimizer_jpg_level', (int) $_POST['ewww_image_optimizer_jpg_level'] );
			if ( empty( $_POST[ 'ewww_image_optimizer_png_level'] ) ) $_POST['ewww_image_optimizer_png_level'] = '';
			update_site_option( 'ewww_image_optimizer_png_level', (int) $_POST['ewww_image_optimizer_png_level'] );
			if ( empty( $_POST['ewww_image_optimizer_gif_level'] ) ) $_POST['ewww_image_optimizer_gif_level'] = '';
			update_site_option( 'ewww_image_optimizer_gif_level', (int) $_POST['ewww_image_optimizer_gif_level'] );
			if ( empty( $_POST['ewww_image_optimizer_pdf_level'] ) ) $_POST['ewww_image_optimizer_pdf_level'] = '';
			update_site_option( 'ewww_image_optimizer_pdf_level', (int) $_POST['ewww_image_optimizer_pdf_level'] );
			$_POST['ewww_image_optimizer_lossy_skip_full'] = ( empty( $_POST['ewww_image_optimizer_lossy_skip_full'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_lossy_skip_full', $_POST['ewww_image_optimizer_lossy_skip_full'] );
			$_POST['ewww_image_optimizer_metadata_skip_full'] = ( empty( $_POST['ewww_image_optimizer_metadata_skip_full'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_metadata_skip_full', $_POST['ewww_image_optimizer_metadata_skip_full'] );
			$_POST['ewww_image_optimizer_delete_originals'] = ( empty( $_POST['ewww_image_optimizer_delete_originals'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_delete_originals', $_POST['ewww_image_optimizer_delete_originals'] );
			$_POST['ewww_image_optimizer_jpg_to_png'] = ( empty( $_POST['ewww_image_optimizer_jpg_to_png'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_jpg_to_png', $_POST['ewww_image_optimizer_jpg_to_png'] );
			$_POST['ewww_image_optimizer_png_to_jpg'] = ( empty( $_POST['ewww_image_optimizer_png_to_jpg'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_png_to_jpg', $_POST['ewww_image_optimizer_png_to_jpg'] );
			$_POST['ewww_image_optimizer_gif_to_png'] = ( empty( $_POST['ewww_image_optimizer_gif_to_png'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_gif_to_png', $_POST['ewww_image_optimizer_gif_to_png'] );
			$_POST['ewww_image_optimizer_webp'] = ( empty( $_POST['ewww_image_optimizer_webp'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_webp', $_POST['ewww_image_optimizer_webp'] );
			if (empty($_POST['ewww_image_optimizer_jpg_background'])) $_POST['ewww_image_optimizer_jpg_background'] = '';
			update_site_option( 'ewww_image_optimizer_jpg_background', ewww_image_optimizer_jpg_background( $_POST['ewww_image_optimizer_jpg_background'] ) );
			if (empty($_POST['ewww_image_optimizer_jpg_quality'])) $_POST['ewww_image_optimizer_jpg_quality'] = '';
			update_site_option( 'ewww_image_optimizer_jpg_quality', ewww_image_optimizer_jpg_quality( $_POST['ewww_image_optimizer_jpg_quality'] ) );
			$_POST['ewww_image_optimizer_disable_convert_links'] = ( empty( $_POST['ewww_image_optimizer_disable_convert_links'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_disable_convert_links', $_POST['ewww_image_optimizer_disable_convert_links'] );
			if ( empty( $_POST['ewww_image_optimizer_cloud_key'] ) ) $_POST['ewww_image_optimizer_cloud_key'] = '';
			update_site_option( 'ewww_image_optimizer_cloud_key', ewww_image_optimizer_cloud_key_sanitize( $_POST['ewww_image_optimizer_cloud_key'] ) );
			$_POST['ewww_image_optimizer_auto'] = ( empty( $_POST['ewww_image_optimizer_auto'] ) ? false : true );
			update_site_option('ewww_image_optimizer_auto', $_POST['ewww_image_optimizer_auto']);
			if ( empty( $_POST['ewww_image_optimizer_aux_paths'] ) ) $_POST['ewww_image_optimizer_aux_paths'] = '';
			update_site_option( 'ewww_image_optimizer_aux_paths', ewww_image_optimizer_aux_paths_sanitize( $_POST['ewww_image_optimizer_aux_paths'] ) );
			$_POST['ewww_image_optimizer_enable_cloudinary'] = ( empty( $_POST['ewww_image_optimizer_enable_cloudinary'] ) ? false : true );
			update_site_option('ewww_image_optimizer_enable_cloudinary', $_POST['ewww_image_optimizer_enable_cloudinary']);
			if ( empty( $_POST['ewww_image_optimizer_delay'] ) ) $_POST['ewww_image_optimizer_delay'] = '';
			update_site_option( 'ewww_image_optimizer_delay', (int) $_POST['ewww_image_optimizer_delay'] );
			if ( empty( $_POST['ewww_image_optimizer_maxmediawidth'] ) ) $_POST['ewww_image_optimizer_maxmediawidth'] = 0;
			update_site_option( 'ewww_image_optimizer_maxmediawidth', (int) $_POST['ewww_image_optimizer_maxmediawidth'] );
			if ( empty( $_POST['ewww_image_optimizer_maxmediaheight'] ) ) $_POST['ewww_image_optimizer_maxmediaheight'] = 0;
			update_site_option( 'ewww_image_optimizer_maxmediaheight', (int) $_POST['ewww_image_optimizer_maxmediaheight'] );
			if ( empty( $_POST['ewww_image_optimizer_maxotherwidth'] ) ) $_POST['ewww_image_optimizer_maxotherwidth'] = 0;
			update_site_option( 'ewww_image_optimizer_maxotherwidth', (int) $_POST['ewww_image_optimizer_maxotherwidth'] );
			if ( empty( $_POST['ewww_image_optimizer_maxotherheight'] ) ) $_POST['ewww_image_optimizer_maxotherheight'] = 0;
			update_site_option( 'ewww_image_optimizer_maxotherheight', (int) $_POST['ewww_image_optimizer_maxotherheight'] );
			$_POST['ewww_image_optimizer_resize_existing'] = ( empty( $_POST['ewww_image_optimizer_resize_existing'] ) ? false : true );
			update_site_option( 'ewww_image_optimizer_resize_existing', $_POST['ewww_image_optimizer_resize_existing'] );
			if (empty($_POST['ewww_image_optimizer_disable_resizes'])) $_POST['ewww_image_optimizer_disable_resizes'] = array();
			update_site_option('ewww_image_optimizer_disable_resizes', $_POST['ewww_image_optimizer_disable_resizes']);
			if (empty($_POST['ewww_image_optimizer_disable_resizes_opt'])) $_POST['ewww_image_optimizer_disable_resizes_opt'] = array();
			update_site_option('ewww_image_optimizer_disable_resizes_opt', $_POST['ewww_image_optimizer_disable_resizes_opt']);
			if (empty($_POST['ewww_image_optimizer_skip_size'])) $_POST['ewww_image_optimizer_skip_size'] = '';
			update_site_option('ewww_image_optimizer_skip_size', (int) $_POST['ewww_image_optimizer_skip_size'] );
			if (empty($_POST['ewww_image_optimizer_skip_png_size'])) $_POST['ewww_image_optimizer_skip_png_size'] = '';
			update_site_option('ewww_image_optimizer_skip_png_size', (int) $_POST['ewww_image_optimizer_skip_png_size'] );
			$_POST['ewww_image_optimizer_parallel_optimization'] = ( empty( $_POST['ewww_image_optimizer_parallel_optimization'] ) ? false : true );
			update_site_option('ewww_image_optimizer_parallel_optimization', $_POST['ewww_image_optimizer_parallel_optimization']);
//			$_POST['ewww_image_optimizer_defer'] = ( empty( $_POST['ewww_image_optimizer_defer'] ) ? false : true );
//			update_site_option('ewww_image_optimizer_defer', $_POST['ewww_image_optimizer_defer']);
			$_POST['ewww_image_optimizer_include_media_paths'] = ( empty( $_POST['ewww_image_optimizer_include_media_paths'] ) ? false : true );
			update_site_option('ewww_image_optimizer_include_media_paths', $_POST['ewww_image_optimizer_include_media_paths']);
			$_POST['ewww_image_optimizer_webp_for_cdn'] = ( empty( $_POST['ewww_image_optimizer_webp_for_cdn'] ) ? false : true );
			update_site_option('ewww_image_optimizer_webp_for_cdn', $_POST['ewww_image_optimizer_webp_for_cdn']);
			//if (empty($_POST['ewww_image_optimizer_webp_cdn_path'])) $_POST['ewww_image_optimizer_webp_cdn_path'] = '';
			//update_site_option('ewww_image_optimizer_webp_cdn_path', $_POST['ewww_image_optimizer_webp_cdn_path']);
			add_action('network_admin_notices', 'ewww_image_optimizer_network_settings_saved');
		}
	}
	// register all the common EWWW IO settings
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_debug', 'boolval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpegtran_copy', 'boolval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_level', 'intval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_level', 'intval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_level', 'intval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_pdf_level', 'intval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_lossy_skip_full', 'boolval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_metadata_skip_full', 'boolval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_delete_originals', 'boolval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_to_png', 'boolval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_to_jpg', 'boolval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_to_png', 'boolval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp', 'boolval' );
	register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_background', 'ewww_image_optimizer_jpg_background' );
//.........这里部分代码省略.........
开发者ID:recetasdemama,项目名称:wordpress,代码行数:101,代码来源:common.php


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