This is a very simple change that adds a drupal_alter hook into the wysiwyg_template_load_all function. This allows developers to modify the array just prior to presentation in the template plugin. The advantage of adding this hook (as an example) is that you could contextually modify the options presented to users based on who they are or add a default image if one hasn't been provided.

I've got this working the textbook module to add in a default image for each packaged (as a feature) template. This way you don't need to create file references just to have a packaged template included by default on a new site using the modules.

CommentFileSizeAuthor
#1 template-alter-hook-1915464-1.patch337 bytesbtopro
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

btopro’s picture

included patch to add a hook_wysiwyg_templates_load_alter hook

guybedford’s picture

Status: Needs review » Closed (fixed)

Sure, no reason not to. I've added this to the current 7.x dev branch.

btopro’s picture

Status: Closed (fixed) » Needs review

In looking at the patch as it was applied it was added to the wrong line. It should be outside the loop as the patch indicates but was applied inside the foreach loop, causing it to be called too many times but also not at the right point in the operation to be effective.

guybedford’s picture

Status: Needs review » Closed (fixed)

Thanks for catching this! You can see we need a new maintainer... Have fixed.