alt text reconciliation
-
My problem is that a lot of images have their alt and captions set inside posts not in media library. I would like to make a one time reconciliation of these items so that values from the post meta populate alt and caption values in media library. Can this be accomplished with your plugin?
-
Thanks for your question, which is closely related to this recent support topic:
Changed ALT text doesn’t not reflect in published posts
I regret that the current MLA version does not have any features that would help you with this task. However, given that two topics have been started along similar lines, I will investigate the work required to implement a custom plugin that might accomplish your goal.
It would be very helpful if you could post a few examples of the source text for posts that include alt text and (especially) captions you want to process. You wrote “values from the post meta“, but my understanding is that this information is in the body/content of the post or page, not its
postmeta
(custom field) content.Any additional details or examples you can supply would be most helpful. Thanks for your help and your patience while I look into this possibility.
Yes you are correct that captions for the images in the post make up the body of the post, alt text set in the post only is what I called by mistake postmeta. This is s wrong term for it. From workflow point of view it was easier sometime just do bulk upload of images into the media library and then set captions and alt text when inserting into the post.
That creates this mess I am in. If you can point me in the right direction on how to at least find these values that would help. What functions return these? What do you mean by source text? Here is how code looks:
<div id=”attachment_6320″ class=”wp-caption aligncenter” style=”width: 434px”><div itemscope itemtype=”https://schema.org/Photograph”><img itemprop=”image” class=”wp-image-6320 size-full” src=”https://www.fpimages.com/wp-content/uploads/2015/03/chateau-frontenac-old-quebec-winter-romantic-getaways-1.jpg” alt=”Monument to S. Champlain and Chateau Frontenac at sunset” width=”434″ height=”650″ /><h4 itemprop=”description” class=”wp-caption-text”>Monument to S. Champlain and Chateau Frontenac</h4></div></div>Thank you for your update with the additional details and for your patience in awaiting my response.
I have created a custom plugin, “MLA Insert Fixit”, which will copy ALT Text values from a post/page insert to the Media Library item. It will also copy ALT Text values from a Media Library item to an insert in a post/page. I would be happy to share the plugin with you for your testing and feedback.
I would like to extend the plugin to handle caption values, but I am a bit confused by the “code” you give as an example. How exactly did you create the inserts that generated this code?
You asked “What functions return these?” – referring to the inserted image, ALT Text and Caption values, I assume. The short answer is that there are no functions that return this information. The MLA “where-used” feature works by extracting all of the file names from Media Library items and then scanning the
post_content
field (with the PHP functionpreg_match_all()
) of every post and page to see if the file name appears in the content. The new “MLA Insert Fixit” tool works in a similar way. For the ALT Text values this is reliable because theimg
tag and thesrc
andalt
attributes have a fixed structure. There is no such structure for Caption values.You asked “What do you mean by source text?” What I mean is the text you see when you edit a post or page and click the “Text” tab in the editor. I believe the “code” you give as an example is what I called the “source text”; is that right?
So, back to Caption values. If you edit a post/page and click “Add Media”, the Media Manager Modal (popup) “Insert Media” Window appears. If you then click on an image you can see the ATTACHMENT DETAILS pane on the right-hand side of the window, with a text box for Caption. Anything you enter here is immediately updated in the Media Library item, so there is no synchronization problem.
When you click “Insert into Post” (or Page), HTML code is inserted in the post_content field for the post/page. It looks something like this (an example from my test system):
[caption id="attachment_3120" align="alignnone" width="181"]<img src="https://mladev/wp-content/uploads/2015/04/XMP-Inga-Ness-181x300.jpg" alt="XMP-Inga-Ness.jpg" width="181" height="300" class="size-medium wp-image-3120" /> Inga Ness - February 1965[/caption]
As you can see, this is quite different from your examples. If I write the MLA Insert Fixit tool to handle the WordPress-standard Caption code it will not work for your examples.
If you can confirm that your “code” comes from the Text tab of the post/page Editor, that would be helpful. If you can tell me how you generate your code it will help me adapt my tool to your needs. Any additional information you can provide will be helpful.
In the interim, if you would like to experiment with the MLA Insert Fixit tool I can send you a copy. You can give me your contact information using the Contact Us page at the FTJ web site:
Do not post your e-mail address in the forum; personal details in a public forum violates WordPress guidelines. If you have trouble accessing the FTJ site, post a note here with your country of origin and I can temporarily unblock it.
Thanks for your help with this new tool and for your interest in the plugin.
thanks for your reply I will look into it little bit later.
right now fighting 4.3 upgradeI hope you were able to work through the WP 4.3 upgrade. It has been two months since the last post in this topic, and I hope the above suggestions proved helpful.
I am marking this topic resolved, but please update it if you still need help populating ALT Text and other values in your Media Library items.
- The topic ‘alt text reconciliation’ is closed to new replies.