How to implement this handy PHP script
-
Hey wordpress breadbins, I have a query. I have found what I hope to be a handy script to re-size all images proportionally. Until now I have used css to set a max width of 530px and height as auto, but the crazy cats over at moicrowswoft developed ie8 which seems to regognise the max width of 530px, but then if any image is put in at full size and has rather large dimensions, then it stretches the height all the way down to the pixel dimension stated in the post. Yes i could change this in the posts but that would mean going through 1000’s of posts to do so. So my question is where would I need to put this script to implement it for the entire of my wordpress site?
<?php
function imageRestrict($image) {
$maxwidth = 530;
list($width,$height) = getimagesize($image);if ($width > $maxwidth) {
$newheight = $maxwidth/$width * $height;
return ‘<img src=”‘.$image.'” width=”‘.$maxwidth.'” height=”‘.$newheight.'”>’;
}else{
return ‘<img src=”‘.$image.'” width=”‘.$width.'” height=”‘.$height.'”>’;
}
}
?>Thanks a lot anyone who replies…
- The topic ‘How to implement this handy PHP script’ is closed to new replies.