2

When you have have an image field on a content type, and use the Insert button to place it into the body, do you get a chance to theme it in Drupal 7? theme_image doesn't seem to get called, and I am not seeing anything the the API refernce. I know this is JS functionality on the edit page, but there could be ways to still theme it. Thanks.

Edit for clarification:

When you use Insert to get images into the body, just the image gets inserted and the theme system gets bypassed. If you use the image as a field, then all modules get a chance to theme it. This results in inconsistent image usage on a site.

For example, if I use an image as a field, the RDF module will tack on some metadata and my custom theme_image will do its thing. When I use Insert with the same image, just the plain image gets put in.

On previous projects, I have added some javascript to the theme to fix these discrepancies, but the code needs to be adjusted each time something changes with how images get themed. Ideally, I am searching for a method to allow images-as-fields and image-inserted-into-body to be themed the same way, without resorting to Javascript or manually editing the images in the body. If this isn't built-in functionality, I may try to patch the Insert module to allow it.

2
  • I haven't been able to find any modules that allow you to change wrapping HTML and img tag properties (meta data) within an Insert module type functionality. If you're looking to create custom functionality yourself, I would probably recommend patching or forking Image Resize Filter instead of Insert, since Image Resize Filter already provides options to manipulate items being inserted with the Insert module.
    – sheena_d
    Commented Jan 16, 2012 at 22:56
  • That's what I figured. I did a long search for a D6 solution a while ago, and was hopeful that things had changed for D7.
    – mpdonadio
    Commented Jan 18, 2012 at 1:28

1 Answer 1

2

I will assume you are referring to using the Insert module.

Once you have inserted an item into a node field (most likely the body), it then becomes a simple string of text within that field and is processed as such. There is no longer anything linking it to the image field that you used to upload it, and no way to hook onto it and perform any programatic changes. The only "theming" that can be done to the image at this point is CSS changes.

You could potentially add optional styles for the images via your WYSIWYG's configuration or you could use the Image Resize Filter module to allow the node editor to change the size of the image and/or create a link to the full-size image.

If you could give some details about what exactly you are wanting to do to that images that have been added via the Insert module, there might be another solution someone can suggest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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