web-dev-qa-db-ja.com

小さい画像から大きい画像へのサイズ変更

元の画像は小さいですが、大きな画像を作成したいです。

私は私のメディアライブラリにオリジナルの画像1024 x 768を持っています、そして私は私のWordPress投稿でこれらの画像を1920 x 1080 pxにサイズ変更したいです。

私はadd_image_size( 'large'、1920、1080、true)を使いました。

しかしそれはうまくいきません、大きな画像サイズを得るために何をすべきか教えてください

1
user3762572

ここで解決策を見つけました:

http://www.binarynote.com/how-to-perfectly-upscale-image-in-wordpress.html

function binary_thumbnail_upscale( $default, $orig_w, $orig_h, $new_w, $new_h, $crop )
{
    if ( !$crop ) return null; 
    $aspect_ratio = $orig_w / $orig_h;
    $size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
    $crop_w = round($new_w / $size_ratio);
    $crop_h = round($new_h / $size_ratio);
    $s_x = floor( ($orig_w - $crop_w) / 2 );
    $s_y = floor( ($orig_h - $crop_h) / 2 );
    return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
}
add_filter( 'image_resize_dimensions', 'binary_thumbnail_upscale', 10, 6 );

Gurung氏が言うように、それは理想的ではなく、Wordpressは理由で大規模化しませんが、自分のしていることを知っていてWordpressを特定のニーズに合うフレームワークとして使用すれば、仕事は完了です。私の場合は、グリッドレイアウトの問題をいくつか解決しています。

助けになれば幸いです。

2
Baylock