Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#14 | media-displaycaption-2369125-14.patch | 1.02 KB | afsch |
#8 | Screen Shot 2015-01-28 at 21.41.20.png | 25.47 KB | cllamas |
Comments
Comment #1
valgibson CreditAttribution: valgibson commentedI 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?
Comment #2
steinmb CreditAttribution: steinmb commentedAlso make sure that the view mode embedded images get rendered through expose the field (/admin/structure/file-types/manage/image/display)
Comment #3
valgibson CreditAttribution: valgibson commentedWhat 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?
Comment #4
steinmb CreditAttribution: steinmb commentedMmm 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...
Comment #5
valgibson CreditAttribution: valgibson commentedOk, 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:
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..
Comment #6
steinmb CreditAttribution: steinmb commentedThis one might be related #1792738: Allow custom file view modes for WYSIWYG display
Comment #7
valgibson CreditAttribution: valgibson commentedComment #8
cllamas CreditAttribution: cllamas commentedI have the same problem , when adding image to the CKEditor I don't get the thumbnail.
Has anybody found a reason or solution?
Comment #9
steinmb CreditAttribution: steinmb commented@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.
Comment #10
afschI 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.
Comment #11
afschComment #12
steinmb CreditAttribution: steinmb as a volunteer commentedComment #14
afschComment #15
steinmb CreditAttribution: steinmb as a volunteer commentedComment #17
brockfanning CreditAttribution: brockfanning commentedThe 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.
Comment #18
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedRecent 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