WordPress – Postie パッチメモ その2

大きな画像を指定の幅に自動的で縮小してくれるのはいいんだけど、
小さな画像も指定の幅に拡大してしまうという不具合が発覚。
これ、なんとかならないのかな、と思って、プラグイン作者のブログを読み進めたら、こんなコメントが書き込まれていました。

I don’t like the way Postie resizes images. It only lets you specify the maximum width. What this does is result in images that are in landscape mode ending up a lot smaller than images that are in portrait mode. Aesthetically, it’s not a good look. I’ve posted the changes I made to fix this at: http://thejoshis.org/donutello/?p=6

早速の彼のブログから長々としたパッチをもらい、これでOK!と喜んでいたら、さらにそこへはこんなコメント。

This can be done easier by changing only the DetermineScale as so… The width you set in the options is the max width or height. It won’t enlarge images that are smaller than that.

function DetermineScale($width,$height, $max_width, $max_height) {
$max_dim = ($width > $height) ? $width : $height;
return ($max_dim > $max_width) ? ($max_width/$max_dim) : 1;
}

すばらしい!! 先人たちの知恵に感謝。



About Me

塩入友広【しおいり・ともひろ】
SHIOIRI Tomohiro
元・工作機械メーカー電気制御設計
活性化で価値向上!

・第二種電気工事士
・第三級アマチュア無線技士
・防災士
・放送大学全科履修生(2023-)
・上田市遺族会西塩田支部長
・元上田市消防団第十六分団副分団長
・元上田市消防団音楽隊副隊長
・元塩田公民館手塚分館長
・元手塚青少年健全育成会長

Radio Amateur JE0EQH

しおいり せんきょ

最近の投稿

アーカイブ

https://twitter.com/shioiri