Drupal: how to re-order Scald Contexts editor-friendly

I use the Scald module on some projects to add images to a CKEditor powered text field. I like the Scald module very much. It gives the editor the freedom or re-using images or actually all kinds of meda across the website while providing a media pool for easy access to all previously uploaded media. Every photo, every image gallery, every video ever uploaded to a website is accessible from every Scald-enabled node. No redundant media, less searching for images, more time for actually writing good articles and maybe even an extra break.

Additionally Scals gives the editor different display options for images, triggered through scald contexts. So for example the editor may choose to have a ‘full width image’ and later change the context to ‘inline image’. This can help getting the workflow organized when working in teams – but it also helps to separate content from code.

This basically this all just works just fine – but when having a couple of ‘contexts’ up, it can be a bit annoying that I can not determine in which order the contexts are presented in the modal window that lets editors change the image’s Scald context. So after a while it can become a bit messy:

Scald-Contexts list of Image-Formats

I would love to have the Scald contexts either ordered alphabetically or ideally manually by drag-and-drop. Currently the contexts seem to be ordered chronologically. So at the moment the first context I created is first in the list – the latest context is last. Some of my contexts are close to others and I would need to have them appearing accordingly close to each other – in the above screenshot it’s “Partner–Logo (160px)” (which I created earlier) and “Partner-Logo (200px)”.

I recently opened an issue at drupal.org regarding this feature request – but I only have half-good news: “You can alter the list of contexts with hook_scald_wysiwyg_context_list_alter –– check the scald.api.php … “. Well – yesss. I guess for now I’m fine with how the list is displayed – but will have a look at this in the future whenever I might run into this particular problem again. Here’s the issue: ‘How to re-order Scald Contexts’ https://www.drupal.org/node/2514352

Workaround: I figured out a way how to kind-of re-arrange the order of Scald contexts to have it a bit more editor-friendly. It is actually a bit risky – but just a bit. Here’s the quick’n’dirty how-to: since all custom contexts are in chronological order, you can kind-of determine the order by deleting and re-installing selected contexts. This will first break your articles – or actually only the images won’t be shown for the time when the corresponding context is not available. But once you re-add the context again (with identical name) all images are back in place – and the ‘new’ context is now at the bottom of the list since it’s the one that was added latest. Hope this helps.

to be continued…

Leave a Reply

Your email address will not be published. Required fields are marked *