The image field named: field_events_foto. Default insert style: Original image.

I copy to my themes the files insert-image.tpl.php - module(insert) sees it.
I rename ant try to use insert-image--field-events-foto.tpl.php, image-insert-image--field-events-foto.tpl.php - module does not see all them :(.
The cache is cleared each time. Where's the problem?


quicksketch’s picture

Title: The insert does not see my template » Provide per-field template suggestions
Category: bug » feature

Insert module does not provide per-field template suggestions (though that's a good feature request, which is where I've moved this). It only provides per image-style suggestions. So you can have templates like image-insert-image--thumbnail.tpl.php or image-insert-image--large.tpl.php.

For the insert-image.tpl.php we don't provide any suggestions at all. I think making those by field name sounds like a good idea. Are you using an image preset with your example or just trying to insert the original image?

jack-pl’s picture

So you can have templates like image-insert-image--thumbnail.tpl.php or image-insert-image--large.tpl.php

I copied image-insert-image.tpl.php file from module templates directory and paste to mytheme/templates, but it's not working.

I've tried also:


these files aren't working either.. The cache is cleared. Tested on clean installation of Drupal 7.22

jordi_bcktt’s picture

I have exactly the same problem

boshtian’s picture

Same problem here.

Image style name is content_image, my template name is image-insert-image--content-image.tpl but it's not working.

boshtian’s picture

As soon as I published comment, I realized what I'm doing wrong.

If you're using admin theme, the template files must be in there, because you use that template when editing content.

mesch’s picture

Issue summary: View changes

+1 for this feature. Perhaps it would be sufficient to add in helpful variables to the template preprocessors that would allow everyone to create their own theme hook suggestions. I can see the following as being especially useful:

- field name
- entity type
- entity bundle

mesch’s picture

In case it's of use to anyone else out there, here is how I applied markdown templates I created to one content type only. It's obviously a bit of a hack, but a functional hack nonetheless.

 * Implements hook_form_FORM_ID_alter() for [type]_node_form
function [theme]_form_[type]_node_form_alter(&$form, &$form_state) {
  // Flag the form for the insert template preprocessors
  // Note this hook is invoked before the #after_build function insert_element_process()
  $markdown = &drupal_static(__FUNCTION__, TRUE);

 * Implements hook_preprocess_HOOK() for insert_image
 * Repeat for each template type you're overriding
function [theme]_preprocess_insert_image(&$variables) {
  $markdown = &drupal_static('[theme]_form_[type]_node_form_alter');
  if (isset($markdown)) {
    // Do any necessary preprocessing for your own markdown templates

    // Make sure your mardown template is used
    $variables['theme_hook_suggestion'] = $variables['theme_hook_original'] . '__markdown';