Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function beautyImg($img, $w, $h)
- {
- $img = (substr($img, 0, 1) == '/' && substr($img, 0, 4) !='http') ? substr(base_url(), 0, -1) .$img : $img;
- list($width, $height) = getimagesize($img);
- $scale_ratio = $width / $height;
- $sr = $w / $h;
- ?>
- <img style="<?php echo ($scale_ratio < $sr) ? 'width:' .$w .'px;margin-top:-' .intval((intval($w / $scale_ratio) - $h) / 2) .'px': 'height:' .$h .'px;margin-left:-' .intval(($h * $scale_ratio - $w) / 2) .'px'; ?>" src="<?php echo $img; ?>"/>
- <?php
- }
Add Comment
Please, Sign In to add comment