Page no: M27
Explanation |
Video and Pics |
NEW: Show Media –> Caption OLD: Post–>Media->Caption |
Screen of WordPress DB Model needed here. -> I can’t get what you want |
First Solution: Set Dot
|
|
Currently the team must set dot to the caption every single time, because otherwise the caption does not appear into the frontend of the website. This task is to avoid manual team work to set the dot on images. We need to force WP to search and show caption tag. |
|
AlternativesSet Dot when image is addedThis method is not possible because WordPress allow editing and enhancing its functionalities with filters, hooks and actions. We need to create a plugins which use the filters which already exists. WordPress does not have filters for every single functionality, only for the needed functionalities. This is the problem here. There is no such filters, which we can use and execute to add dot to caption automatically when the image is added. We can add this piece of code in the core WP, but on next update it will disappear and we must add it again. |
|
Set Dot Automatically via Syndication ToolsThis is a method to be used if the first solution is not working. We will create a new syndication tools function which will go trough recent posts and will change the content and set dot to the posts which does not have the same way as the other functionalities of the Syndication Tools have. |
|
Preferred: Show Media->Caption Directly
|
|
How it works?
Before we show the post, we take the full content of the post and search for all images in the text. Then we search for all captions + images in the text. Then we know how many images we have and which of them are without caption. If we add the caption twice, it will be shown twice. After that for every single image which does not have a caption, we generate the shortcode for the caption. There are parameters, which we must reproduce:
For the params, we need to search the code of the img attribute and find with a regex the setted with of the image, extract align and attachment id from the class attribute. Then we generate the new caption shortcode and replace the old content of the image with the new one (including the caption). |
|
Tests
|
See more for