Alter WYSIWYG settings in Drupal

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

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; }




