Title: [Plugin: Auto Post Thumbnail] Adding Shortcode
Last modified: August 20, 2016

---

# [Plugin: Auto Post Thumbnail] Adding Shortcode

 *  [Travis Smith](https://wordpress.org/support/users/wpsmith/)
 * (@wpsmith)
 * [15 years ago](https://wordpress.org/support/topic/plugin-auto-post-thumbnail-adding-shortcode/)
 * Recently I used this plugin and Auto Featured Image, but both didn’t do what 
   I wanted them to do.
 * So investigating their code, they were only searching the content pre-shortcode
   execution. So if anyone is using a shortcode to post images or videos, then this
   plugin wasn’t working so well.
 * So for Auto Post Thumbnail, in the file auto-post-thumbnail.php, if you insert
   `
   $post_content = do_shortcode($post[0]->post_content);` above `preg_match_all('/
   <\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*)/i', $post[0]->post_content, $matches);`
   and change `preg_match_all('/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*)/i',
   $post[0]->post_content, $matches);` to `preg_match_all('/<\s*img [^\>]*src\s*
   =\s*[\""\']?([^\""\'>]*)/i', $post_content, $matches);` then it will execute 
   shortcodes before assigning the post thumbnail. This is important for those who
   use shortcodes to display images (or even videos in Auto Featured Image Plugin).

The topic ‘[Plugin: Auto Post Thumbnail] Adding Shortcode’ is closed to new replies.

 * ![](https://ps.w.org/auto-post-thumbnail/assets/icon-256x256.gif?rev=3469511)
 * [Auto Featured Image (Auto Post Thumbnail)](https://wordpress.org/plugins/auto-post-thumbnail/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/auto-post-thumbnail/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/auto-post-thumbnail/)
 * [Active Topics](https://wordpress.org/support/plugin/auto-post-thumbnail/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/auto-post-thumbnail/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/auto-post-thumbnail/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Travis Smith](https://wordpress.org/support/users/wpsmith/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/plugin-auto-post-thumbnail-adding-shortcode/)
 * Status: not resolved