Closed (fixed)
Project:
Scald: Media Management made easy
Version:
7.x-1.x-dev
Component:
Library/DnD
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Jan 2014 at 13:28 UTC
Updated:
31 Aug 2015 at 20:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
davidhk commentedSplit the issue into separate tasks
Comment #2
davidhk commentedI'll need a way to change the html that is generated when I drop the atom, so instead of it starting:
<!-- scald=33:sdl_editor_representation -->it should start
<!-- scald=33:sdl_editor_representation {"link":"http:/atom/33"} -->I think if I do that, when I save the page the atom will be linked to its page as desired.
But I'm not sure what's the easiest way to make it happen. I think it's a common enough requirement that it could be an Admin setting. eg a drop-down "Default link target", with three options: none / atom's page / custom url. Where would be the right place to put this in Scald?
Or I could just put it into code for now. But I can't find a hook that will let me make this change easily. There is hook_scald_prerender, but that needs me to build a custom provider to use it, which seems like overkill. Would it be possible to allow an ordinary module to implement this hook?
Any other suggestions welcome, as I am going around in circles.
Comment #3
davidhk commentedI still haven't worked out the best way to do this. Any pointers please?
Comment #4
jcisio commentedI can see two options:
- Override the scaldEmbed theme function.
- Extend (patch) Scald so that data returned in Drupal.dnd.fetchAtom can contain a default "options" (hook_scald_atom_default_options(_alter)?) and modify the scaldEmbed theme to use it if it is available.
Comment #5
davidhk commentedThanks for the tips. I took a look, but unfortunately both are also called when I edit an atom properties, not just when I insert. I want the user to be given a default link when they insert an atom, but be able to edit and override it if they want.
However I've found that the dnd library is built using
function scald_dnd_library_add_item(&$library, $sid) {and that it ends
I've used that hook and it seems to be working ok. Am I likely to have any problems later doing it this way?
Comment #6
scotwith1tI started to do an implementation of hook_scald_dnd_library_item_alter but there seems to be an issue. It looks like the only place sas2array is called is on the drop event, so the new "Insert" and double-click options for inserting into the ckeditor dom don't take into consideration any library item modifications. I may be doing something wrong, but it works fine on dnd, but not on insert or double-click. Is there a simple way to patch the plugin.js file to consider the clicking of the insert link?
Filing as a bug because this seems to be a failure of that hook to consider the insert and double-click options that were added to core.
Comment #7
davidhk commentedThe new plugin dndck4 includes fixes that allow the code above to work on drop, insert, and double-click:
https://www.drupal.org/node/2136415
So I'd recommend using that.
Comment #8
scotwith1tNot sure if it does or not, but I'll check it out. In the meantime, I worked out that insertAtom doesn't consider the options parameter of scaldEmbed. I just overrode insertAtom to run the sas through sas2array, get the options (altered by hook_scald_dnd_media_library_alter()).
Just in case the use case is useful to anyone else, here's our implementation of hook_scald_dnd_media_library_alter(), linking the image atoms to their raw full-size image file instead of the atom page as described above.
Comment #9
scotwith1tBump. Any chance we can confirm or deny that this is a deficiency of Scald or just something about the implementation I've described?
Comment #10
scotwith1tIf this was fixed/changed in 1.3, we haven't gotten around to updating yet but will consider that as an option, especially if it addresses this issue. Any feedback on this is appreciated.
Comment #11
nagy.balint commentedIf you mean comment #7, that is only available in the dev version.
Comment #12
scotwith1tWe have since realized that, in working towards upgrading to 1.4, our project has far too much code that is dependent on the sas markup to consider moving forward with the dndck4 plugin. Any way that this could be more permanently fixed so that sas2array is called on other events besides drop? Thankfully, you guys have been conscious of the need for the sas markup to continue to work, so for that I'm very grateful! :)
Comment #13
nagy.balint commentedUnfortunately the old dnd plugin is in legacy status right now, which means that of course if someone can provide a patch, and we can get confirmation that it works, or if there is some serious bug in the old system, then we are open to commit the patch, or to fix the serious issue. However it is unlikely to receive any new feature development.
On the other hand if you can describe the code that depends on the sas markup, then maybe we can figure out a way to still upgrade to the new version.
Comment #14
nagy.balint commentedAt any rate i would still recommend upgrading to the latest version even if you keep using the legacy dnd plugin.
Comment #15
scotwith1tSorry for reviving this issue in the first place, as it looks like this is fixed in 1.4 anyway! Before, only if I dragged and dropped would I get the custom implementation of library_item_alter with the link but a test with 1.4 revealed all 3 actions working the same as they should! Thx!
Comment #16
scotwith1tNo, definitely not fixed. After some extensive testing, there is still something definitely wrong with the way this is working. If I use hook_scald_dnd_library_item_alter() as mentioned above to add a link to the default sas markup, drag and drop works fine but Insert and Double-click do not. I cannot seem to figure out why that is. I will continue to investigate, but to me this constitutes something fundamentally broken that has never been addressed. It shouldn't matter what method you use to insert the atom into the RTE, the use of the hook should be considered in all 3 cases.
Comment #17
nagy.balint commentedAnd that refers back to comment #7 I believe.
I would still suggest to consider more to upgrade to dndck4, as the legacy plugin will only receive legacy support, which is not too much at the moment. Of course if you can provide a patch, i will be happy to review it.
Comment #18
scotwith1tUnfortunately for our site "upgrading" is, for many reasons, just not possible right now (mainly that all our custom code breaks as soon as I tried!). I would happily provide a patch but I can't seem to nail down where the difference is. Can you look and help me figure out where the discrepancy is in how the 3 methods handle things? I think it boils down to scaldEmbed not being passed the options array when it's first run using insert or double-click but it IS passed the options when you DnD.
Comment #19
nagy.balint commentedIsnt it possible for you to describe what custom code breaks when you try dndck4?
Cause on our sites, there was never any custom code that depended on the sas code.
Do you have some custom filters that cannot be replaced?
Comment #20
scotwith1tIn a nutshell, the main thing that breaks is a custom module that lets the user specify a caption, credit and link (title and url) and this makes up the value of the legend field without actually giving them access to the legend field. I guess it's primarily because we're using custom versions of the onShow and onOk methods from the atomProperties dialog box.
Regardless, let's focus on the point at hand if we can: the method for inserting an atom into CKEditor should not matter. It should (and always should have) consider(ed) the fact that a library item can be altered using a Scald API hook (hook_scald_dnd_library_item_alter) and that when it is inserted into the textarea it may already have options on it that need to be considered. DragNDrop handles this nicely, Insert and Double-click do not.
I will continue figuring out why because I can't spend the time to try and upgrade this site to use the new plugin; the size and scale of this site would help you understand if I could say which one and get into the details, but I can't! If I could, the Scald team would have a really nice one to brag about on the project page! ;)
Comment #21
scotwith1tSeems like this does the trick for us. Don't know if it breaks other stuff yet...
Not sure, but I think the inconsistency comes from the fact that the drop event was the only one which ran things through the sas2array to get the options and then does a fetchAtom, runs that through scaldEmbed theme function with the context and options, then insertElement into the editor. The other 2 events are just calling insertAtom, which doesn't look at options at all...something like that anyway. :)
Comment #22
scotwith1tComment #23
nagy.balint commentedComment #24
nagy.balint commentedComment #25
nagy.balint commentedThis patch should be fine.
Comment #27
nagy.balint commentedThanks, Committed.
Comment #28
scotwith1tThanks for the moral support. :) I knew I could figure out a way to fix it if I stuck with it.