Title: [Plugin: Auto Post Thumbnail] Help! Need better parsing of image filename
Last modified: August 20, 2016

---

# [Plugin: Auto Post Thumbnail] Help! Need better parsing of image filename

 *  [thadb](https://wordpress.org/support/users/thadb/)
 * (@thadb)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-post-thumbnail/)
 * Hi,
    I’m using the Auto Post Thumbnail plugin to use the first image in the post
   as the thumbnail, when the feature image does not exist. The images are URLs 
   to a WordPress.org blog that we have and for the most part the plugin works great,
   but for some reason, we have some images in those posts that the plugin does 
   not parse out correctly. In particular, it doesn’t strip out any arguments that
   might be tacked on to the end of the filename. WordPress.org puts arguments at
   the end of filename like this…
 *     ```
       <img src="http://www.domain.com/images/myimage.jpg?w=300&h=298" alt="" width="300" height="298" />
       ```
   
 * So, the plugin doesn’t chop of the “?w=300…” after the file extenstion and it
   fails. Anyone know how to fix this or know of a better plugin?
 * From what I gather, this seems to be the function the plugin uses to fetch the
   image…
 *     ```
       /**
        * Function to fetch the image from URL and generate the required thumbnails
        */
       function apt_generate_post_thumb($matches, $key, $post_content, $post_id)
       {
           // Make sure to assign correct title to the image. Extract it from img tag
           $imageTitle = '';
           preg_match_all('/<\s*img [^\>]*title\s*=\s*[\""\']?([^\""\'>]*)/i', $post_content, $matchesTitle);
       ```
   
 * Thanks!
 * Thad

The topic ‘[Plugin: Auto Post Thumbnail] Help! Need better parsing of image filename’
is closed to new replies.

## Tags

 * [fail](https://wordpress.org/support/topic-tag/fail/)

 * 0 replies
 * 1 participant
 * Last reply from: [thadb](https://wordpress.org/support/users/thadb/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-post-thumbnail/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
