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.
When I try to upload a file (image or other type) via the "add media" button in ckeditor. After choosing the file and selecting default format, I only see a generic file icon instead of a linked filename with generic file icon.
Comment | File | Size | Author |
---|---|---|---|
#4 | ckeditor-media-plugin-files-1898958-4.patch | 770 bytes | iSoLate |
#3 | ckeditor-support-document-tokens-1898958-3.patch | 5.48 KB | kevinchampion |
#1 | ckeditor-media_plugin_default_format-1898958.diff | 813 bytes | filsterjisah |
Comments
Comment #1
filsterjisah CreditAttribution: filsterjisah commentedin sites/all/modules/contrib/ckeditor/plugins/media/library.js function stripDivs seems to also strip spans (which is wrapper arround the format output) and look for img tag (our generic icon).
I've added a patch, please test & review.
Comment #2
kevinchampion CreditAttribution: kevinchampion commentedThis works for me to give me both the generic icon and linked filename.
Comment #3
kevinchampion CreditAttribution: kevinchampion commentedOn second look, while this works to make the generic icon and linked filename appear and be formatted correctly, it doesn't address the fact that the document is not being tokenized like an image is. The reason the above patch works is because when documents are embedded they are just printed as html. The javascript goes through a step to strip out any surrounding elements around the image, in order to only work with the image element, in order to tokenize it. So, the above works if you don't mind document embeds just being html and not media tokens.
The attached patch includes a method for using the above to keep the plugin from stripping out the filename link, and also converting the document to a media token. It does this by removing the span wrapper and filename link when the editor detaches, and adding back the span wrapper and filename link when the editor attaches.
With this in place, it is then just a matter of working upstream to get the icon and filename link to appear properly when the document is rendered via theme file_link on output to the page. It looks like this may be able to be accomplished by hooking into file_link or media's own hook_media_token_to_markup_alter().
Comment #4
iSoLate CreditAttribution: iSoLate commentedDoesn't work for me. Added a patch for my problem which was that I couldn't show any file at all using the ckeditor together with the media module.
Comment #5
caktux CreditAttribution: caktux commentedPatch in #3 works great here.
Comment #6
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedconflict with this ckeditor patch to fix media issue:
https://drupal.org/node/1504696#comment-7719339
Comment #7
PI_Ron CreditAttribution: PI_Ron commentedHas anyone got ckeditor + media successfully embedding files/documents other than images?
Comment #8
wwalc CreditAttribution: wwalc commentedI'd like to encourage everyone to test instead the following code: #2159403: Make CKEditor plugin system modular and clean
Comment #9
hkirsman CreditAttribution: hkirsman commentedPI_Ron, got the file embedding working Media dev + Media CKEditor dev + CKEditor dev!