title: edit my get first image function
body: <p>in my wp_theme i have this function to get first image of post as thumbnail</p>
  
  <pre><code>function get_first_image() {
  global $post;
  $first_img = '';
  preg_match_all( '/&lt;img.+src=[\'"]([^\'"]+)[\'"].*&gt;/i', do_shortcode( $post-&gt;post_content, 'gallery' ), $matches );
    $first_img = isset( $matches[1][0] ) ? $matches[1][0] : null;
  
  if ( empty( $first_img ) ) {
          return get_template_directory_uri() . '/assets/images/empty.png'; // path to default image.
  }
  
      // Now we have the $first_img but we want the thumbnail of that image.
      $explode = explode( '.', $first_img );
      $count = count( $explode );
      $size = '-150x150'; // Our panel ratio (2:1) 312x156 for lighther page, 624x312 for retina; use add_image_size() and Force Regenerate Thumbnails plugin when changing sizes.
      $explode[ $count -2 ] = $explode[ $count -2 ] . '' . $size;
      $thumb_img = implode( '.', $explode );
      return $thumb_img;}
  </code></pre>
  
  <p>but some image have custome size and this function not work on this case</p>
  
  <p>like this :
  <a href="https://yawar.ir/wp-content/uploads/2014/08/yawar-1024x682.jpg" rel="nofollow noreferrer">https://yawar.ir/wp-content/uploads/2014/08/yawar-1024x682.jpg</a></p>
  
  <p>how can i force change the url of images that have another size ?</p>