When the module inserts code referencing the image, could this be wrapped inside div tags that typically accompany CCK imagefield elements? This would help greatly in themeing. I am using the latest version and applied the patch for working with Lightbox, which works great by the way!

An example of the issue is when I insert an image inside a text field, I'd like to have text wrap around the image. I typically do this with imagefield images by styling that image type. The same can be done here if the field type divs were included. The below shows what I'm talking about for a CCK image field named "articlephoto":


<div class="field field-type-filefield field-field-articlephoto">
   <div class="field-items">
       ...code inserted from filefield_insert here...
   </div>
</div>

Can this be done using the filefield_insert provided tpl files? If so, how?

Comments

quicksketch’s picture

After applying the patch for CCK Formatters, none of the .tpl.php files are used any longer, so they won't be much help to you. I'd suggest adding whatever classes you need by theming the actual formatters. Just find the function outputting your image in whatever module is providing the formatter, such as theme_lightbox_name_of_theme_function(). Copy/paste it into template.php in your theme, rename to [my_theme]_lightbox_name_of_theme_function() and add whatever classes are necessary.

diodata’s picture

Thanks. This works great! Thanks for your help.

However, one small issue. It's probably more of a lightbox issue. I'm using LIghtbox, imagecache, CCK imagefield, etc... The appropriate formatter in the lightbox module is

function theme_imagefield_image_imagecache_lightbox2 (lightbox2.formatter.inc file)

The nid is empty, which is needed for lightbox grouping in some cases. Apparently, $node->nid and $item['nid'] are empty. Could this be because it's being evaluated on an node edit page? (I'm getting around it by manually editing the inserted code.)

Could this be part of the default output of filefield_insert? It seems like when adding CCK fields, using the same div wrapping as other CCK fields would he with layout and styling. I wouldn't know how to style these specific images any other way. Just a thought. Is this even possible through filefield_insert?

diodata’s picture

Actually, I just adding the following to get around it. I put this inside the formatter function I added to template.php. Not great, but it works.


  $n = explode("/",$_GET['q']);
  $item['nid'] = $n[1];

quicksketch’s picture

FileField Insert is not capable of knowing the NID in all cases, for example on node/add/[type], there is no NID that's been assigned, so it's impossible to know what the NID will be. Your solution works fine I think, though it won't work in Views or when the node is displayed on the front page. An equivalent of what you've done is to simply say $item['nid'] = arg(1), but again there's no guarantee that this argument will actually contain the Node ID.

diodata’s picture

Thanks again for your help. And thanks for the explanation about nid; makes sense. Things have been working smoothly so far.

I should rephrase part of my last post. Could wrapping in the divs be part of the default rendering of filefield_insert? To me this makes sense since it's how other CCK fields are rendered, and I still don't see any other good way to style. Is it possible to always know the CCK field name?

quicksketch’s picture

Status: Active » Closed (fixed)

If anywhere, this will be implemented in #479310: Add support for add'l CCK Formatters (Lightbox2, etc.).