I'm using the File Entity module to add extra fields to images, such as caption. File Entity alt tags also aren't working with insert. I was wondering, how can I go about making these modules work together, will I have to use a custom image-insert.tpl.php, or is it something to do with allowing insert to read extra values in the file widget?

Thanks in advance.

Comments

stevieegee’s picture

Did you manage to get the modules playing together? I am in the same boat.

stevieegee’s picture

Issue summary: View changes

Grammar

sachbearbeiter’s picture

Issue summary: View changes

same question: Did you manage to get the modules playing together? I am in the same boat.

sachbearbeiter’s picture

i only did a short attempt:

image-insert-image.tpl.php

additional:

<?php 
$captionItem = field_get_items('file', $file, 'field_file_image_caption_text');
$captionText = $captionItem[0]['safe_value'];
?>

initial from insert:

<img src="<?php print $url ?>" <?php if ($width && $height): ?>width="<?php print $width; ?>" height="<?php print $height; ?>" <?php endif; ?>alt="__alt__" title="__title__" class="image-<?php print $style_name ?><?php print $class ? ' ' . $class : '' ?>" />

additional:

<?= $captionText ?>  

works, but you have to fill the fields and save the node and reload ...

as quicksketch writes:

 * Note that ALT and Title fields should not be filled in here, instead they
 * should use placeholders that will be updated through JavaScript when the
 * image is inserted.

@quicksketch it would be really nice if you can write two lines, how you deliver for example the __alt__ and __title__ values via js to the texfield ...

br sb

sachbearbeiter’s picture

collecting:

https://drupal.org/node/1344290

Any module may implement hook_insert_widgets() to specify which fields that widget provides. Insert will then pick up those fields with JavaScript and make them available as replacements in the insert-image.tpl.php file, which you can override in your theme. Take a look at imagefield_insert_widgets() in includes/imagefield.inc, which could be modified and placed into either a custom module or directly into imagefield_extended.module to make it so that Insert could utilize the fields provided by that module.

lukus’s picture

Hi

I managed to get these playing together by exposing values stored in the $item array.

e.g. for caption (which I'm providing via description) ..

print $item['description']

Hope this helps

L

Snater’s picture

Browsing through old tickets while working on the module's D8 version. I had a look at that issue and I do not see that happening. This would require adding a whole new dimension to the Insert module. Insert compiles the HTML to insert from pregenerated templates that are filled with particular content extracted from the form's fields using JavaScript. As far as I can see without being a regular File Entity user, there is no way, at least not without using another module, to retrieve an entity's fields per JavaScript directly in the form. Probably, retrieving those fields would at least require implementing some complex AJAX functionality. The quote of comment #4 is absolutely correct, but that applies to generating the form--at that moment is is not known which file entities are selected. You could only provide information on entities that are already stored in the form. __alt__ and __title__ fields are simply retrieved by accessing the corresponding form fields using JavaScript.
I do not see a way to easily combine Insert and File Entity. When selecting a file entity, its fields would need to instantly be accessible. Apart from that, Insert would need to support random or custom replacement variables, which would require a fundamental architectural change of Insert. It might even be easier to implement Insert functionality directly into a module depending on File Entity, instead of interfacing to the Insert module.
I tend towards closing this ticket as won't fix, as it would result in a massively complex design contradicting with the intention of Insert. It is just out of scope. That said, I will leave this ticket open for a few more weeks, as I might be wrong on some assumptions.

Snater’s picture

Status: Active » Closed (won't fix)

As per last comment.