0

I'm trying to add additional CSS class to a field after the field is added. But not for all fields of that particullar content type, but only for those, that editor would like to. Like a module Formatter_field lets user to chose the field format - I have an image field and couple of different image formats, which I can chose after I upload an image which formatter_field.

I cannot find anywhere a solution, how to add additional css class to the same field.

For example:

User uploads an image via image field, using formatter_field he/she choses image format from image_cache and then adds CSS class wich adds border. Then adds another image to the same node (as image field is set to "unlimited"), choses different format and adds different CSS class, which gives different border to that image. And all this in one node.

update:

In my exact case I want to create a horizontal gallery, where images and texts are shown inline horizontally in such a way, that some of the pictures are bigger, some are smaller and are aligned in different heights and sometimes between those pictures there are text blocks with explanations about the works. Like in on a real gallery wall. :) Would be great that all one gallery is one node as it is easier to edit.

1

You could try theme_field as well

Returns HTML for a field.

This is the default theme implementation to display the value of a field. Theme developers who are comfortable with overriding theme functions may do so in order to customize this markup. This function can be overridden with varying levels of specificity. For example, for a field named 'body' displayed on the 'article' content type, any of the following functions will override this default implementation. The first of these functions that exists is used:

  1. THEMENAME_field_body_article()
  2. THEMENAME_field__article()
  3. THEMENAME_field__body()
  4. THEMENAME_field()
0

Forget my answer about the theme, you have to either hook_form_alter() the node-edit form or find your way through Field API in a custom module for starters

Got it, you have to either hack image_field_widget_process() in image core module (really bad idea) or follow this very good answer

  • Thanks for the tip! I've looked through the "very good answer", but I have never written any module by myself, so it looks a bit too complicated to me. Maybe you could drop me a line in regards on from where should I start this? :) – Benas Plentas Mar 20 '13 at 19:45

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.