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.
Contexts have defined formats. Some of them only applies to images for example. However currently the 'edit atom properties' button in the wysiwyg lists all the contexts.
It would be nice if when clicking on an image and pressing this button, the dialog would only list the contexts that are for images. And the same with any type. If i click on a video, it should not display all the contexts that only apply for images.
Also it is possible that the site has many contexts for images for example (used at site building lets say), but we would like if the client could only select from a selected few.
Comment | File | Size | Author |
---|---|---|---|
#5 | wysiwyg-relevant-context-list-1951134-5.patch | 2.7 KB | nagy.balint |
#3 | wysiwyg-relevant-context-list-1951134-3.patch | 2.68 KB | nagy.balint |
#1 | wysiwyg-relevant-context-list-1951134-1.patch | 2.1 KB | nagy.balint |
Comments
Comment #1
nagy.balint CreditAttribution: nagy.balint commentedI created a patch which solves these issues.
In dnd.module i changed the way it constructs the context list for the settings. The contexts are listed for each type as a subarray.
Then instead of creating the itemlist for the select before the dialog is created, I create it in the onShow function where the current atom is already fetched, and the type can be retreived. Then with the type i can construct the itemlist that is for the given type only.
I added a drupal_alter call in dnd.module to let other modules alter the contexts array that is passed to the settings. That solves the last point.
Comment #2
jcisio CreditAttribution: jcisio commentedHaven't tested, patch looks good, even with variable names. It's also the idea we had when we implemented the wysiwyg context feature, but we chose an easy approach first.
It'd be nice to document the new hook in scald.api.php (yes, we have this file recently).
Comment #3
nagy.balint CreditAttribution: nagy.balint commentedHere is the updated patch with the api documentation.
Comment #4
nagy.balint CreditAttribution: nagy.balint commentedComment #5
nagy.balint CreditAttribution: nagy.balint commentedRerolled patch.
Comment #6
jcisio CreditAttribution: jcisio commentedCommitted http://drupalcode.org/project/scald.git/commit/2a767bd. However there are two things:
- Generally speaking, formats are not "types", but for file format (jpg or png) or file MIME type, and to be used with transcoder. The "formats" for contexts are currently not used anywhere, to we don't filter contexts with formats now, just the "hidden" property.
- To hide some contexts from end users, we could introduce a "system" property for context. It is different from "hidden": hidden context would be possible to configured by admin and hidden from end user, while system contexts are hidden from both.
Also, we needs a change notice/improved doc.
Comment #7
Mindless-dupe CreditAttribution: Mindless-dupe commentedThese is a great feature and we exactly looked for something like this.
But do you have a quick sample
Thank you very much !
Comment #8
jcisio CreditAttribution: jcisio commented- The example for hook_scald_wysiwyg_context_list_alter() was in the same commit (in scald.api.php).
- "Hidden" contexts (like "no-access", "invalid-id" etc.) are defined in hook_scald_contexts or hook_scald_contexts_alter(), however they are not configurable. So I suggested introduce a new property: "system". But I'm not sure it makes sense. Maybe a "wysiwyg" property, defaults to TRUE?
Comment #9
jcisio CreditAttribution: jcisio commentedChange record created http://drupal.org/node/1993154. Other issues could be done in follow-ups if necessary.