1

I have a content type named "Affiliate" which has among others a field storing a logotype image. The image is then displayed in a ticker (jCarousel) using a dedicated image style.

After I created one node and attached a logotype to it, I made several copies of that node, differing in text, but sharing same image. I was aware of situations where a logotype has to change but thought that solution would be "scalable" due to the fact that the image reference is shared. Now - kaboom! - the image has to be replaced with a new version. I thought I'd get away if I replaced the original image on the server and then deleted the derivative styled copies from the styles directory to make Drupal recreate them afresh. No go.

The problem is that the new image is used but with old dimensions (both in the node display and ticker), which causes distortions. I have to relink the node with the image, one by one to make it notice the new dimensions. Is the size of the original image stored somewhere in the node? What is the sneakiest way to go in such situations?

0

The image width and height are stored in the field tables (field_data_FIELD_NAME/field_revision_FIELD_NAME), in the FIELD_NAME_height and FIELD_NAME_width columns.

If you know the file id (fid) of the file you need to change the data for, and the width and height of your new image, you can just run the following queries against the database:

UPDATE field_data_FIELD_NAME 
SET FIELD_NAME_width = WIDTH, FIELD_NAME_HEIGHT = HEIGHT
WHERE FIELD_NAME_fid = FID

UPDATE field_revision_FIELD_NAME 
SET FIELD_NAME_width = WIDTH, FIELD_NAME_HEIGHT = HEIGHT
WHERE FIELD_NAME_fid = FID
3
  • Wonderful, thanks! That should be a built-in tool. You saved my... approach. – Artur May 6 '12 at 14:22
  • Yeah I was kinda surprised it's not built in but if you think about it there's no central place for managing image files so it does makes sense. I'd wager there's probably a module out there somewhere that does it ;) – Clive May 6 '12 at 14:27
  • I tried to edit/update/refresh that image in admin/content/file table (provided by Media, I guess) but it did not give any results. So, yes, if you have Media installed there is a central place, though I would gladly welcome such an admin tool in ANY place, really :) – Artur May 6 '12 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.