One thing which our users have found unintuitive about this module is that the description field is not used when inserting links. For instance, say I upload a PDF file named "Brochure 2010-01-30 v2.pdf", and then give it a description of "Brochure". When I click the Insert button, I would like to see the text in my WYSIWYG as "Brochure", rather than the (usually) non-sensical uploaded file name.
Is that something which can be configured already? If not, can this be the default behavior? Perhaps if there is no description field, or if it is empty, then use the filename; otherwise, use the value in the Description field.
Comment | File | Size | Author |
---|---|---|---|
#30 | insert_description_or_filename-d6.patch | 4.59 KB | quicksketch |
#30 | insert_description_or_filename-d7.patch | 5.49 KB | quicksketch |
#28 | insert-709562-28.patch | 1.47 KB | johannesdr |
#18 | description-filled-in.png | 33.06 KB | geerlingguy |
#16 | filefield_sources_remote_munge.patch | 1.51 KB | quicksketch |
Comments
Comment #1
quicksketchYou can change the behavior by theming the inserted content. Just copy the insert-link.tpl.php file to your theme directory and make whatever changes you want. Then clear your Drupal caches so that the new .tpl.php file will get picked up.
Comment #2
geerlingguy CreditAttribution: geerlingguy commentedIs there a possibility this could be a configurable option in the Insert settings for the filefield? This is pretty much a baseline requirement for all the sites on which I install this module, and it's never fun to create more .tpl.php files for an already crowded theme directory :-/
Comment #3
joelstein CreditAttribution: joelstein commentedI agree with geerlingguy; this is a pretty obvious default behavior. Besides, I tried changing the contents of insert-link.tpl.php from...
...to...
...which works, but only if there is a value in the description field. If there is no value in the description field, then an empty <a> tag is inserted, which is not obvious to the average user.
What would it take to change this behavior? Shall I submit a patch?
Comment #4
joelstein CreditAttribution: joelstein commentedSorry, in that last comment I tried to write <a> and messed up the formatting.
Comment #5
geerlingguy CreditAttribution: geerlingguy commentedTo fix this, we could either have the file name automatically populate the description field, or perhaps have the __description__ placeholder revert to the filename if the description is empty... ?
Patch would be great.
For now, I'm using
... which at least prints the -
file_name.ext
if there is no description.Comment #6
perandre CreditAttribution: perandre commented+1 for using description if available by default.
Comment #7
Maguar CreditAttribution: Maguar commentedWhen I shake Inserts inserted code with the wrong encoding for example
<a class = "highslide_formatter_default highslide" href = "/% 3Cimg% 20src% 3D% 22http% 3A /% 252F.... %22%20alt%3D%22%22%20title%3D%22%22%20%20class%3D%22imagecache%20imagecache-highslide_full%20imagecache-default%20imagecache-highslide_full_default%22%20/%3E">
Where to find the error? FCKEditor or Insert. Pleace Help
Comment #8
pribeh CreditAttribution: pribeh commentedQuad-super Bump.
Comment #9
igorik CreditAttribution: igorik commentedThere is no description for images too.
I inserted a few images, but in the code of images, there is no description I filled for each of these images.
Comment #10
igorik CreditAttribution: igorik commentedchanged to bug report, image could be inserted completely with description
Comment #11
quicksketchThis is not a bug since it is not the intended behavior as it was designed. Not all files have descriptions to use. If someone writes a patch I'll review it, but I don't have a personal need for such functionality.
Comment #12
igorik CreditAttribution: igorik commentedHi, thanks for quick reply.
IMHO Filefield = file + it's description(if it has some).
You wrote that no all files have description - yes, if there is no description, no text info is inserted. Same as it is now.
And while the file has some description, it could be inserted together with the file (title, or alt, and some text under the image), if not, the filefield info is not complete.
Comment #13
gooddesignusa CreditAttribution: gooddesignusa commentedI would also like this functionality. I will try to write a patch when i have some time. Using geerlingguy example but modifying it with some logic to just check before it prints.
Comment #14
riisi CreditAttribution: riisi commentedsubscribing
Comment #15
geerlingguy CreditAttribution: geerlingguy commentedPerhaps this could be implemented in the same way as core's File Attachments work...
When a user uploads the file, the file name is inserted as the file attachment description automatically (replacing underscores and/or dashes with spaces). Then the description would always be used, no matter what, and this issue would be moot.
Of course, this would probably have to be an issue over in the FileField queue... maybe a checkbox in the filefield's settings for 'Use file name as Description' for fields that have the Description enabled for use...
Comment #16
quicksketchAs far as I know, if a description is empty in Upload module, it uses the file name also. Forgive crudeness but I'm just attaching a file directly to Drupal.org to demonstrate.
Comment #17
quicksketchYep, so it seems that "no description" == "use file name" in Upload.module also.
I think the request here is just to default the description to the file name and keep all other behaviors the same. I should note that if this change moves forward, it should be addressed in Drupal 7 first, which now uses FileField and defaults to no description also.
Comment #18
geerlingguy CreditAttribution: geerlingguy commentedWell, yes; however, immediately after the file is uploaded, the Description is filled in with the file name, and then the user may delete that description and add his own, or simply modify what's there. I find that to be much more intuitive than having a blank description, then showing the filename after saving... (see attached - I didn't have to type in the file name).
Maybe I'm just confusing what you said in the last post...
Comment #19
quicksketchYes, I'm just saying if you delete the Description that is pre-filled for you, Upload.module uses the file name on display. So we couldn't "always just use the description" because the description may be empty. FileField already acts like Upload module on display, the only difference is upon uploading a file.
Comment #20
geerlingguy CreditAttribution: geerlingguy commentedOkay, I see.
Comment #21
mherchelIs there any way that someone can program something like: If Description exists, then write description. If not, then just write filename?
I tried for a while, but I can't get the isset or empty php functions to correctly detect if the description was filled in (I'm obviously not a programmer)
Comment #22
quinns CreditAttribution: quinns commentedI figured this out, at least in the context of my projects. If you are using a different "admin theme" than your front-end theme, you need to copy the template files into your admin theme folder.
Comment #23
aiphesi suscribe to this feature...very useful for basic contributor.
Comment #24
attheshow CreditAttribution: attheshow commentedSubscribing.
Also, I believe this should be marked as a "feature request" based on the discussion above, so I'm changing that as well.
Comment #25
sylvain_a CreditAttribution: sylvain_a commented+1
Comment #26
mzwyssig CreditAttribution: mzwyssig commentedSubscribing. Any news on this feature request ?
Comment #27
pribeh CreditAttribution: pribeh commentedThe maintainer has noted that they will not be working on this feature so it would make sense for someone else to begin work on it. I will see if I can get a developer to start work on this soon. Anybody else willing to pitch in bounty-wise?
Comment #28
johannesdr CreditAttribution: johannesdr commentedWhy is __description__ used in the template file, while all other data is available in php variables?
I made a simple change to the template_preprocess_insert_link function and the insert-link template to pass the description as php variable. This solves joelsteins problem in #3
Patch is included.
Comment #29
quicksketchBecause description and __alt__ are not known until the user clicks the Insert button. So imagine this use-case:
- User visits node/add/story.
- User enters title of node.
- User selects an image to upload and clicks "Upload". At this point an AJAX request is made and the file is handled. The returning HTML includes the file name, the "Remove" button, the empty Alt and Description fields, and the "Insert" button.
- The user enters the Alt and Description.
- The user clicks Insert, which reads the Alt and Description text from the fields and swaps them into the template, then inserts the template into the body field.
So in short, you can't use a PHP variable because it will always be empty for new files or it won't be accurate for files if the user changes the description before clicking insert, since Insert doesn't make any kind of AJAX request when inserting a file (which it shouldn't, it already has all the information necessary on the front-end side).
Comment #30
quicksketchWell, given enough time I suppose I may eventually get to anything (14 months later). This patch adds support for several new tokens:
I've also made "__description_or_filename__" the default token for file links inserted, so if you enter a description it will be used as the text of the link, otherwise the filename will be used. As usual, you can theme the existing tpl.php files if you want to change the default behavior.
Comment #31
perandre CreditAttribution: perandre commented*Like* :)
Comment #32
geerlingguy CreditAttribution: geerlingguy commentedDouble like. Thank you so much for this! Will there be a new release posted soon, or should I grab it from git?
Comment #33
quicksketchYeah I *just* posted the 1.1 release. So you can try it out as soon as the packaging script finishes. Drush usually has a slight delay before releases become available.
Comment #34
joelstein CreditAttribution: joelstein commentedSweet! Thank you for adding this.