Generate image with Drupal imagecache before using imagecache_create_path & getimagesize
Posted
by ozke
on Stack Overflow
See other posts from Stack Overflow
or by ozke
Published on 2010-06-03T11:33:51Z
Indexed on
2010/06/03
12:14 UTC
Read the original article
Hit count: 299
Hi guys,
I'm using imagecache_create_path() and getimagesize() to get the path of a imagecache-generated image and its dimensions. However, if it's the first time we access the page that image doesn't exist yet and imagecache_create_path doesn't generate it either.
Here's the code:
// we get the image path from a preset (always return the path even if the file doesn't exist)
$small_image_path = imagecache_create_path('gallery_image_small', $image["filepath"]);
// I get the image dimensions (only if the file exists already)
$data_small = list($width, $height, $type, $image_attributes) = @getimagesize($small_image_path);
Is there any API method to get the path AND generate the file? In other words, can I generate the image (using a preset) from PHP without showing it in the browser?
Thank you in advance
© Stack Overflow or respective owner