If I use a token like [node:field_image:custom_style:width], I expect the width of the styled image. Instead, I'm getting the width of the unstyled upload (the width/height of the image stored in the database). Am I doing something wrong?

Thanks!
Rob

Comments

thirdender’s picture

Issue summary: View changes
doubouil’s picture

StatusFileSize
new9.15 KB

It's normal, code use the file object value, which are the original image width and height.

Here's my version where I generate the derivative image and then use get_image_info() to grab the generated image width and height, as expected. I Also added mimetype value in token values since last version of Metatag Open Graph accepts them, and get_image_info() returns it so might as well use it ! Also supports imagecrop module.

Feel free to reuse/make a patch of it !

Edit : You need to edit Line 111 to " if ($images_style_sizes[$styled_uri]["width"] && $images_style_sizes[$styled_uri]["height"]) {", I used getimagesize() before get_image_info() )

damienmckenna’s picture

Component: Documentation » Code
Category: Support request » Bug report
Status: Active » Needs review
StatusFileSize
new2.59 KB

Here's a patch based upon doubouil's code.

damienmckenna’s picture

Status: Needs review » Needs work

Needs to be rerolled.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new2.93 KB

Rerolled, and I added some comments.

damienmckenna’s picture

damienmckenna’s picture

StatusFileSize
new3.33 KB

After some testing, this appears to work reasonably.

damienmckenna’s picture

Status: Needs review » Fixed

Committed.

  • DamienMcKenna committed 4f5d053 on 7.x-1.x
    Issue #2344465 by doubouil, DamienMcKenna: Fixed the image height,...
doubouil’s picture

I just updated with rc1 my production environment where I initially made the patch, still works as expected (metatags returns imagecroped width and height). I'd say this issue is cleared for 1.0.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.