Title: WordPress size images
Last modified: March 22, 2017

---

# WordPress size images

 *  [Xavierator](https://wordpress.org/support/users/xavierator/)
 * (@xavierator)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/wordpress-size-images/)
 * Dear,
 * I would like to get width and height of WordPress images with PHP, something 
   like this:
 * $imgINFO = getimagesize(‘[http://smartcommunity.es/wp-content/uploads/2017/03/yyyy.png&#8217](http://smartcommunity.es/wp-content/uploads/2017/03/yyyy.png&#8217););
 * $imgINFO = getimagesize(‘[http://smartcommunity.es/wp-content/uploads/2017/03/Avatar-1.jpg&#8217](http://smartcommunity.es/wp-content/uploads/2017/03/Avatar-1.jpg&#8217););
 * It doesn’t works, I can’t get images information, I only get an empty array.
 * But, if I use the same way to know image information of external WordPress images
   it works fine:
 * $imgINFO = getimagesize(‘[https://www.google.es/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png&#8217](https://www.google.es/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png&#8217););
 * $imgINFO = getimagesize(‘[http://www.sport.es/img/logo.png&#8217](http://www.sport.es/img/logo.png&#8217););
   …
 * Someone knows how can I get the WordPress images sizes with PHP ?
 * Thanks, Xavi

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [Xavierator](https://wordpress.org/support/users/xavierator/)
 * (@xavierator)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/wordpress-size-images/#post-8946123)
 * More information, I can get image info of another WordPress web site like this:
 * $imgINFO = getimagesize(‘[http://www.archertargets.com/images/logos/Facebook_icon_2.png&#8217](http://www.archertargets.com/images/logos/Facebook_icon_2.png&#8217););
 * But I can’t get image information of any image of [http://www.smartcommunity.es](http://www.smartcommunity.es),
   another sample:
 * $imgINFO = getimagesize(‘[http://smartcommunity.es/wp-content/uploads/2017/01/Logo-Smart-Community-Tra.png&#8217](http://smartcommunity.es/wp-content/uploads/2017/01/Logo-Smart-Community-Tra.png&#8217););
 * It isn’t an uploads folder problem because I can’t get image information of a
   image out of uploads folder:
 * $imgINFO = getimagesize(‘[http://smartcommunity.es/wp-content/themes/trades/img/Card-Blank.jpg&#8217](http://smartcommunity.es/wp-content/themes/trades/img/Card-Blank.jpg&#8217););
 * Thanks, Xavi
    -  This reply was modified 9 years, 1 month ago by [Xavierator](https://wordpress.org/support/users/xavierator/).
    -  This reply was modified 9 years, 1 month ago by [Xavierator](https://wordpress.org/support/users/xavierator/).
    -  This reply was modified 9 years, 1 month ago by [Xavierator](https://wordpress.org/support/users/xavierator/).
    -  This reply was modified 9 years, 1 month ago by [Xavierator](https://wordpress.org/support/users/xavierator/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/wordpress-size-images/#post-8946552)
 * If the image you are interested in is attached to a post by using the attachment
   post_type (the normal situation), you can get all sorts of meta data, including
   pixel sizes of each defined size (thumbnail, medium, large, etc.), with [wp_get_attachment_metadata()](https://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata).
 * You will need the attachment post’s ID, which can be found various ways. For 
   example, getting all image attachments whose parent ID is that of the current
   post. Then check the corresponding filenames until the correct attachment post
   is found.
 *  Thread Starter [Xavierator](https://wordpress.org/support/users/xavierator/)
 * (@xavierator)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/wordpress-size-images/#post-8947086)
 * Dear bcworkz,
 * The images has been uploaded by profile WP plugin or ftp with dreamweaver.
 * To get the images information I only have their url.
 * Thanks, Xavi
    -  This reply was modified 9 years, 1 month ago by [Xavierator](https://wordpress.org/support/users/xavierator/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/wordpress-size-images/#post-8949268)
 * I see, thanks for the extra info. AFAICT it appears to be a server configuration
   or security issue for smartcommunity.es. I also am unable to use getimagesize()
   on images on that server. I get:
 * > Warning: getimagesize([http://smartcommunity.es/wp-content/uploads/2017/03/yyyy.png](http://smartcommunity.es/wp-content/uploads/2017/03/yyyy.png)):
   > failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 * The images there open fine in a normal browser. In saving the image, then uploading
   to my server by FTP, getimagesize() works fine, so it is not anything related
   to the image itself or WP in general. It appears to be specific to the smartcommunity.
   es server where file access via PHP is forbidden there.
 *  Thread Starter [Xavierator](https://wordpress.org/support/users/xavierator/)
 * (@xavierator)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/wordpress-size-images/#post-8950160)
 * Ok, thanks for your information, I will contact with my client in order to resolve
   the server security, access, …
 * Thanks, Xavi

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘WordPress size images’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 2 participants
 * Last reply from: [Xavierator](https://wordpress.org/support/users/xavierator/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/wordpress-size-images/#post-8950160)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
