Saber tamaño resultante de aplicar un imagecache

14 April 2011 – 14:00

Rápido miniquick_post drupal theming

A veces necesitamos saber el tamaño de una imagen después de aplicar un preset de imagecache, sobre todo al aplicar presets que no sean crop, sino scale (esto nos puede resultar útil para maquetar listados en los que no sepamos el tamaño de la imagen)

Para ello simplemente debemos hacer lo siguiente, y tendremos el tamaño en el array $size.

$size = image_get_info(imagecache_create_path($presetname, $path));
print $size['width']; // anchura de la imagen resultante
print $size['height']; // altura de la imagen resultante

Fácil y rápido :-)


Publicado originalmente en mi antiguo blog, 3oheme.com, y recuperado de archive.org.

This is the personal website of Ignacio Palomo Duarte, Product Manager. If you're looking for my portfolio and more information just have a look at the homepage, and if you liked this article maybe you can share it on Bluesky.