I've added a field (text-area) for adding captions to my images like when I add an image with the CKeditor, by going to file types > image > manage fields. If I have an stand-alone image field in a content type and I set manage display to rendered file, I get to add and see a caption. But when adding an image inside the CKEditor, I never see the caption. Is there a way I can use my caption field wherever I add images on my site including the CKEditor?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

valgibson’s picture

I ran into the same problem, using media 2.0-alpha4 and ckeditor 1.16 / 4.4.6 library and file-entity 2.0-beta1.

Can someone please tell me if this is a ckeditor issue, a media issue, or a file-entity issue?

What I have found out so far: hook_media_wysiwyg_token_to_markup_alter() is never being fired, because media_wysiwyg_token_to_markup() is never being entered.

Could someone please shine a light on this?

steinmb’s picture

Status: Active » Postponed (maintainer needs more info)

Also make sure that the view mode embedded images get rendered through expose the field (/admin/structure/file-types/manage/image/display)

valgibson’s picture

What I have done so far;

1. I created an extra view mode in a custom module
2. I exposed my extra field in this view mode
3. Add content
4. Use the media button in Ckeditor (defined by ckeditor plugin) to include an image using Media browser
5. Set text for my required field in the Media browser
6. Define that the image should use my custom created view mode
7. Insert the image
8. Look at the front end and can't see my added field

I tried to make use of hook_media_wysiwyg_token_to_markup_alter() and used a debugger to step through the whole process. But this hook was never being fired. Also, when I look at the <img> tag that media has created it looks like this:

<img alt="" class="Doe attr__field_auteur[und][0][value]__John attr__field_file_image_alt_text[und][0][value]__Mountains attr__field_file_image_title_text[und][0][value]__Mountains attr__format__default attr__typeof__foaf:Image img__fid__3 img__view_mode__default media-image" src="http://drupal-7.34-3.local.dev/sites/default/files/pic_20090120213955.jpg" />

Is it supposed to look like this? Am I missing something fundamental?

steinmb’s picture

Version: 7.x-2.0-alpha4 » 7.x-2.x-dev
Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Active

Mmm does not look right to me, though I'm not a maintainer of this module. Just be sure, could pls. step up to dev and do a quick retest? hook_media_wysiwyg_token_to_markup_alter() should have fired...

valgibson’s picture

Ok, I did a clean drupal install and used media-7.x-2.x-dev instead. Now the source of my added image looks like this:

<p><mediawrapper data=""><img alt="" class="file-img-caption media-element" data-fid="2" data-media-element="1" src="http://valerie.drupal-7.34-3.dev/sites/default/files/pic_20090120212358_0.jpg" typeof="foaf:Image" /></mediawrapper></p>

It still doesn't give me the extra fields and after saving the node and editing again, the <mediawrapper> is gone btw, but that has probably something to do with CKEDITOR filtering this out.

Also hook_media_wysiwyg_token_to_markup_alter() is not being fired in the whole process..

steinmb’s picture

valgibson’s picture

cllamas’s picture

I have the same problem , when adding image to the CKEditor I don't get the thumbnail.

Has anybody found a reason or solution?

steinmb’s picture

@cllamas your issue is unrelated to to this. Frankly, I belive it is unrelated to WYSIWYG completely. Have not seen it documented any where that media web browser should generate and thumb after upload, though I agree that would be nice. Pls. head over to #2365089: Media Browser tab "upload": Preview image thumbnail missing and chime in.

afsch’s picture

I researched a bit trying to display the Image Caption in wysiwyg edit mode and I found this solution (patch). I'm not so sure if this solution could work to display other fields but at least for the caption works fine for now.

afsch’s picture

steinmb’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: media-displaycaption-2369125-11.patch, failed testing.

afsch’s picture

steinmb’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 14: media-displaycaption-2369125-14.patch, failed testing.

brockfanning’s picture

The problem with #14 is that it's hardcoded to a particular custom field name (and I think would actually cause javascript errors for sites that don't have a field_caption field).

Have you tried enabling the media_wysiwyg_view_mode module? I haven't tried it myself, but it seems like it might be relevant.

Chris Matthews’s picture

Status: Needs work » 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