Resize images on the fly
- Copy pi.ed_imageresizer.php to
system/expressionengine/third_party/ed_imageresizer/
- Add path variables to your config at
system/expressionengine/config/config.php
:
$config['ed_server_path'] = '/var/www/html/'; // Server path to your site's web root
$config['ed_cache_path'] = '/var/www/html/media/images/resizer_cache/'; // Server path to where your resized images should be stored
$config['server_url'] = 'http://sub.domain.com'; // OPTIONAL - no trailing slash
image
(string) required : the file to resizemaxWidth
(integer) : maximum width of the resized imagemaxHeight
(integer) : maximum height of the resized imageforceWidth
(boolean “yes” or “no”, default “no”) : will force the width, even if the original’s width is lessforceHeight
(boolean “yes” or “no”, default “no”) : will force the height, even if the original’s height is lesscropratio
(string format “integer:integer”) : crops the image to the defined ratiodefault
(string) : a backup image to use if theimage
is not foundalt
(string) : an alt tag for the imageclass
(string) : a class for the image tagid
(string) : an ID for the image tagtitle
(string) : a title for the image taghref_only
(boolean “yes” or “no”, default “no”) : if yes, will return only the href, not the image tagdebug
(boolean “yes” or “no”, default “no”) : will optionally output an error message if one is encountered, otherwise will fail silentlygrayscale
(boolean “yes” or “no”, default “no”) : grayscales the resized imagecrop_align
(string “t”, “r”, “b”, “l” and “c”, default “cc”) : sets the align of crop. First character for horizontal and second for vertical.baseline
(number) : sets the typographic baseline to match the height of image
{exp:ed_imageresizer
image="{my_image_field}"
default="/images/site/default_image.png"
maxWidth="100"
cropratio="100:120"
class="my_class"
alt="Image description"
grayscale="yes"
}
Would then output the following:
<img src="/media/images/resizer_cache/resized_image.jpg" width="100" height="120" alt="Image description" />