EDIT (jan. 2020): Divi Alt Text plugin is no longer free. You can check the new and improved Divi Alt Text plugin.
Hi all, You may be aware that since Divi 3.1, several WordPress hooks have been introduced into the Divi source code. But there's more: module management has been redesigned as well. And that's good news for developpers or power users, for it's way easier now to make changes in modules.
Hence the update of my
free Divi plugin, Divi Alt Text, in charge of automatically fetching images alt texts from WordPress media library for every image related module except Gallery: Image, Fullwidth Image, Blurb, Fullwidth Header, Slider and Fullwidth Slider.
Divi Alt Text redesigned
You will find here the new
code plugin for Divi Alt Text, based on the new Divi code, which is much cleaner than before. The plugin is now way smaller, thanks to the use of a well designed WordPress hook in the modules code.
Note : I removed the Gallery module from the plugin because I couldn't find a clean solution to make it work (the only way I found to get the alt text from the library was to overide the whole module's HTML rendering function, which is too long). Besides, the module gets the image title from the media library to set the alt text, so it's not empty like the other modules.
Getting image alt text from the media library
I still use the same technics to get the alt text from the image URL.
The principle is simple: We first get the image's post ID from its URL, then we get the alt text from the post meta, or the image title if the alt text is not set (which is bad!). Since last version, I added the use of relative path in image URL, starting with '/' and not 'http...', because every single URL should be relative in WordPress.
Modules update: the filter hook
With the arrival of Divi 3.1, I started digging into the modules source files to see if and how it was improved. Great surprise, a lot of code has been factorized and simplified. And even better, there are several WordPress hooks that can be used to dynamically inject PHP.
No need to overide the whole rendering process anymore!
See the official Divi Alt Text plugin page
Meet the new and enhanced Divi Alt Text plugin!