↑ Return to M20 Media Inside Post

M27 Media Caption

Page no: M27


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

Set Dot plugin

Old solution was the team manual to set a dot on all captions.

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.



Set Dot when image is added

This 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 Tools

This 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

We introduce a new plugin called SetDot Automatically. The functionality of the plugin is to force WordPress to show the caption always no matter if it is setted or not.


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:

  • width
  • attachment id
  • align

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).




Test if there is a image without set dot to caption to be forced in frontend to be with caption + mix images with and without caption.


Test link:

Test link here


Expected behavior:

Post with 3 images. One of them is without caption in the admin panel, 2 of them with . as a caption.



Working fine.




See more for M2x Media Inside Posts