A site I've built uses media to display images via the RTE (CKEDITOR) that have two additional txt fields that display with the image. (shows the image + caption + image source)

For example : correct render of caption and source fields

This uses two field templates I have in the following directory :

"/sites/all/themes/MYTHEME/templates/fields/"

the files are "field--field-file-image-caption.tpl.php" and "field--field-file-image-credit.tpl.php"

As per my screen shot above, they do work... most of the time.

On occasion, (Why, I don't know!) the templates I just listed aren't being used. (It appears to default to default field templates)

I'll see this instead : incorrect text styles

I was able to catch it in the act, here's whats get rendered in the browser.

This is the correct render :

<div class="media media-element-container media-wysiwyg_left_align">
  <div id="file-10854" class="file file-image file-image-jpeg">
    <h2 class="element-invisible"><a href="/files/beckmanmodelgchfjpg-2">beckmanmodelgchf.jpg</a></h2>
    
    <div class="content">
      <img alt="The Beckman G pH meter" height="1168" width="835" class="media-element file-wysiwyg-left-align" typeof="foaf:Image" src="/sites/default/files/styles/rte_full_width/public/beckmanmodelgchf_2.jpg?itok=SW0YtvWB">
      
      <div class="image-caption">
        <p>The Beckman G pH meter was produced from 1935 until 1950. At roughly 29 cm (about 11 inches) wide it is large by today’s standards, but measuring pH had required an entire benchtop of equipment before Beckman's first pH meter was introduced in 1934.</p>
      </div>
      <div class="image-credit">
        <i class="ion-android-camera"></i><p>Photograph by Gregory Tobias. CHF Collections.</p>
      </div>
    </div>

  </div>
</div>

Note the
class="image-caption"
and
class="image-credit" with the <i> tag...

This is the incorrect render:

<div class="media media-element-container media-wysiwyg_left_align">
  <div id="file-10854" class="file file-image file-image-jpeg">
  <h2 class="element-invisible"><a href="/files/beckmanmodelgchfjpg-2">beckmanmodelgchf.jpg</a></h2>

    <div class="content">
      <img alt="The Beckman G pH meter" height="1168" width="835" class="media-element file-wysiwyg-left-align" typeof="foaf:Image" src="/sites/default/files/styles/rte_full_width/public/beckmanmodelgchf_2.jpg?itok=bGUgj28C">
      
      <p>The Beckman G pH meter was produced from 1935 until 1950. At roughly 29 cm (about 11 inches) wide it is large by today’s standards, but measuring pH had required an entire benchtop of equipment before Beckman's first pH meter was introduced in 1934.</p>

      <p>Photograph by Gregory Tobias. CHF Collections.</p>
    </div>

  </div>
</div>

Note the MISSING 'image-caption' and 'image-credit' and ...

Here's a screen shot : https://www.drupal.org/files/issues/code_screenshot_rte_compare.jpg

I have no reliable way on how to reproduce this. It just happens at random.
If I flush the cache on production, it goes away, maybe, but 90% of the time it works again (problem goes away)
But, if I come back to the page at another time (This makes me think its PHP/CACHING related) it will randomly be there.
But this is NOT consistent in any pattern in anyway between page to page that uses this code for templating.

Thoughts? Ideas? Solutions?

Thank you!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alphex created an issue. See original summary.

brockfanning’s picture

Do you use a different admin theme? From your description my hunch would be that somehow your entities are being rendered while in the admin theme, which caches the filtered output until the next cache clear. You could test my theory by copying your templates over to the admin theme folder.

FiNeX’s picture

I've the same issue. Clearing the cache fix the problem. I'm also using a different admin theme.

brockfanning’s picture

I believe one example of how nodes might be rendered as if being viewed in the admin theme is simply visiting /admin/content. If you use an admin theme, and you visit /admin/content, all of the nodes in the list get rendered as if they were in the admin theme. You can confirm this by:

1. Clear all caches, and then visit /admin/content (which should use the admin theme)
2. Click on the first node in the list to view it
3. If my hunch is right, it will display incorrectly (field templates aren't used)
4. Clear all caches again, while still viewing the node
5. See if it now displays correctly

Chris Matthews’s picture

Status: Active » Closed (outdated)

Recent versions of media have resolved most of peoples concerns and is compatible with entity translation, multilingual and various advanced configurations. Due to the high volume of inactive and most often irrelevant issues we are Closing this as (outdated). If for whatever reason this issue is important to you AND you still have issues after checking the media recipe documentation, then let us know and we will review your concerns.

Otherwise, see the recipe documentation for how to configure media and for troubleshooting tips OR refer to the media_dev distribution if you want to see a working media setup.

As mentioned, feel free to make some noise in this issue if you still feel it is important to you or someone else.

Thanks,

Media team