Skip to main content

Command Palette

Search for a command to run...

Alter WYSIWYG settings in Drupal

Published
•1 min read•View as Markdown
Alter WYSIWYG settings in Drupal
L

Known for his open source and JavaScript security initiatives, Liran Tal is an award-winning software developer, security researcher, and open source champion in the JavaScript community. He's an internationally recognized GitHub Star, acknowledged for his open source advocacy, and has received the OpenJS Foundation's Pathfinder for Security for his work on Node.js security. His contributions to developer security education include leading OWASP projects, building supply chain security tools, participation in CNCF and OpenSSF initiatives, and authoring books such as O'Reilly's Serverless Security. He leads the developer advocacy team at Snyk.io and is on a mission to empower developers with better application security skills.

Oct 9, 2012 ~ 1 min read

Alter WYSIWYG settings in Drupal

share this story on

Altering WYSIWYG settings to make image URLs absolute so that they are also accessible via Email clients.

If you deliver content notifications over email and that content may have images attached to it, inline in the message, it will badly display an image source that it can’t find. This is because when the WYSIWYG adds the image to the page it sets the image source to be a relative URL such as /system/files/image_1.jpg.

It’s possible to create an alter hook that changes the init settings passed to the WYSIWYG and making every attached image as a full http:// source link.

/**

  • Implements hook_wysiwyg_editor_settings_alter
  • Alters the WYSIWYG editor settings to make URLs for images be absolute (i.e: prefixed with http://)
  • so that they are also accessible via Email clients. */ function my_module_wysiwyg_editor_settings_alter($settings, $context) { $settings['convert_urls'] = TRUE; $settings['relative_urls'] = FALSE; $settings['remove_script_host'] = FALSE; }

More from this blog

Liran Tal's blog

178 posts

Author of Node.js Secure Coding, Awarded GitHub Star and OpenJS Foundation's Pathfinder Award for Security. Security researcher, advocate for open source, web security and kindness.