Requires at least: 4.7.5 Stable tag: trunk License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html Automatically populates Alt…
Author: | Taylor Callsen (profile at wordpress.org) |
WordPress version required: | 4.7.5 |
WordPress version tested: | 4.9.4 |
Plugin version: | 1.1 |
Added to WordPress repository: | 23-02-2018 |
Last updated: | 07-03-2018
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
|
Rating, %: | 0 |
Rated by: | 0 |
Plugin URI: | |
Total downloads: | 1 122 |
Active installs: | 10+ |
Click to start download
|
FAQ
How does it work?
This plugin hooks into the the_content filter on page and post render. Essentially right before post_content (in the form of raw HTML) is set to the browser, this plugin will scan the HTML for tags using a regex matcher. Regex was used instead of parsing the HTML into a Document Object to maximize compatibility (parsing the HTML into a Document Object, and then back to an HTML string would likely modify the HTML syntax, drop attributes, etc. which could break other components and post functionality).
Once images are identified in the HTML, the image src URL is used to lookup the attachment ID corresponding to the image. Unfortunately I was not able to find a cleaner way of performing this lookup, as the image ID is not always output onto the page when an attachment is included.
Once the image ID is determined, the plugin retrieves the image Alt and Title values for that attachment using the get_post_meta() and get_the_title() WordPress functions. Once these values are returned, they are added to the image unless the image already contains an alt or title tag, in which case this part is skipped.
The modified image HTML is placed back into the post_content HTML string, and returned to the browser.
ChangeLog
1.1
- Updated “Tested up to” tag on readme
1.0
- Initial release of functional code and readme