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


PHP _image_get_preview_ratio函数代码示例

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


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

示例1: stream_preview_image

/**
 * Streams image in post to browser, along with enqueued changes
 * in $_REQUEST['history']
 *
 * @param int $post_id
 * @return boolean
 */
function stream_preview_image($post_id)
{
    $post = get_post($post_id);
    /** This filter is documented in wp-admin/admin.php */
    @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
    $img = wp_get_image_editor(_load_image_to_edit_path($post_id));
    if (is_wp_error($img)) {
        return false;
    }
    $changes = !empty($_REQUEST['history']) ? json_decode(wp_unslash($_REQUEST['history'])) : null;
    if ($changes) {
        $img = image_edit_apply_changes($img, $changes);
    }
    // Scale the image.
    $size = $img->get_size();
    $w = $size['width'];
    $h = $size['height'];
    $ratio = _image_get_preview_ratio($w, $h);
    $w2 = max(1, $w * $ratio);
    $h2 = max(1, $h * $ratio);
    if (is_wp_error($img->resize($w2, $h2))) {
        return false;
    }
    return wp_stream_image($img, $post->post_mime_type, $post_id);
}
开发者ID:cybKIRA,项目名称:roverlink-updated,代码行数:32,代码来源:image-edit.php

示例2: stream_preview_image

/**
 * Streams image in post to browser, along with enqueued changes
 * in $_REQUEST['history']
 *
 * @param int $post_id
 * @return boolean
 */
function stream_preview_image($post_id)
{
    $post = get_post($post_id);
    @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
    $img = WP_Image_Editor::get_instance(_load_image_to_edit_path($post_id));
    if (is_wp_error($img)) {
        return false;
    }
    $changes = !empty($_REQUEST['history']) ? json_decode(stripslashes($_REQUEST['history'])) : null;
    if ($changes) {
        $img = image_edit_apply_changes($img, $changes);
    }
    // scale the image
    $size = $img->get_size();
    $w = $size['width'];
    $h = $size['height'];
    $ratio = _image_get_preview_ratio($w, $h);
    $w2 = $w * $ratio;
    $h2 = $h * $ratio;
    if (is_wp_error($img->resize($w2, $h2))) {
        return false;
    }
    return wp_stream_image($img, $post->post_mime_type, $post_id);
}
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:31,代码来源:image-edit.php

示例3: stream_preview_image

function stream_preview_image($post_id)
{
    $post = get_post($post_id);
    @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
    $img = load_image_to_edit($post_id, $post->post_mime_type, array(400, 400));
    if (!is_resource($img)) {
        return false;
    }
    $changes = !empty($_REQUEST['history']) ? json_decode(stripslashes($_REQUEST['history'])) : null;
    if ($changes) {
        $img = image_edit_apply_changes($img, $changes);
    }
    // scale the image
    $w = imagesx($img);
    $h = imagesy($img);
    $ratio = _image_get_preview_ratio($w, $h);
    $w2 = $w * $ratio;
    $h2 = $h * $ratio;
    $preview = wp_imagecreatetruecolor($w2, $h2);
    imagecopyresampled($preview, $img, 0, 0, 0, 0, $w2, $h2, $w, $h);
    wp_stream_image($preview, $post->post_mime_type, $post_id);
    imagedestroy($preview);
    imagedestroy($img);
    return true;
}
开发者ID:nuevomediagroup,项目名称:WordPress,代码行数:25,代码来源:image-edit.php

示例4: stream_preview_image

/**
 * Streams image in post to browser, along with enqueued changes
 * in $_REQUEST['history']
 *
 * @param int $post_id
 * @return bool
 */
function stream_preview_image($post_id)
{
    $post = get_post($post_id);
    wp_raise_memory_limit('admin');
    $img = wp_get_image_editor(_load_image_to_edit_path($post_id));
    if (is_wp_error($img)) {
        return false;
    }
    $changes = !empty($_REQUEST['history']) ? json_decode(wp_unslash($_REQUEST['history'])) : null;
    if ($changes) {
        $img = image_edit_apply_changes($img, $changes);
    }
    // Scale the image.
    $size = $img->get_size();
    $w = $size['width'];
    $h = $size['height'];
    $ratio = _image_get_preview_ratio($w, $h);
    $w2 = max(1, $w * $ratio);
    $h2 = max(1, $h * $ratio);
    if (is_wp_error($img->resize($w2, $h2))) {
        return false;
    }
    return wp_stream_image($img, $post->post_mime_type, $post_id);
}
开发者ID:pjsong,项目名称:WordPress,代码行数:31,代码来源:image-edit.php


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