Title: Re-size image automatically
Last modified: August 18, 2016

---

# Re-size image automatically

 *  Resolved [fouadovic](https://wordpress.org/support/users/fouadovic/)
 * (@fouadovic)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/)
 * Hello :
    When i upload image in the admin area, the image has as default, its
   real size. Can i limit the width of the image (<450px) when uploading (Using 
   GD LIB for exemple)? CSS proprety “max-width” don’t work on IE6, so i have problems
   on displaying pages. Thanks

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/re-size-image-automatically/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/re-size-image-automatically/page/2/?output_format=md)

 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640454)
 * hi fouadovic
 * I am using imagefromjpeg which i borrowed from a friend of mine which seems to
   work well… you can see it here [http://www.estateagencies.co.za/demo](http://www.estateagencies.co.za/demo)
 * The img src attribute looks like, displaythumb.php?imagewidth=450&picture=1234.
   jpg
 * This is what my displaythumb.php looks like:
 * ————————————–
 * // usage : <img src=”displaythumb.php?imagewidth=80&photoid=2874.jpg”>
 * $thumbname = $_GET[photoid];
    $directory = “/home/esp007/public_html/demo/photos”;
   $widthimage = $_GET[imagewidth]; $filename = $directory . ‘/’ . $thumbname; $
   max = $_GET[max]; //$filename = $thumbname; $new_h = $widthimage; // Content 
   type header(‘Content-type: image/jpeg’); // Get new sizes $src_img = imagecreatefromjpeg(
   $filename); $origw=imagesx($src_img); $origh=imagesy($src_img); $ratio=$origw*
   $new_h; $new_w=$ratio/$origh; $dst_img = imagecreatetruecolor($new_w,$new_h);
   imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy(
   $src_img)); imagejpeg($dst_img);
 * ——————————–
 *  Thread Starter [fouadovic](https://wordpress.org/support/users/fouadovic/)
 * (@fouadovic)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640455)
 * Hi taz72 :
    Where i have to copy this code ? I don’t see any option where put
   ma max size (exemple width : 450px and height : calculated “proportionnal”) ?
   Thanks
 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640456)
 * hi fouadovic
 * The code I listed is in the displaythumb.php file, so you copy that code and 
   save it as displaythumb.php. You place the displaythumb.php within your publicly
   visible hosting space, then you call the image by <img src=”displaythumb.php?
   imagewidth=450&photoid=1234.jpg”>
 * It is exactly the same as calling <img src=”1234.jpg”> except you are resizing
   it by calling displaythumb.php
 * The only thing I am not sure about is my photos are already in a folder called/
   photos, so if you upload via wordpress, I am not sure if you get the opportunity
   to specify a path to that image.
 * I will dump the php file at [http://www.estateagencies.co.za/displaythumb.zip](http://www.estateagencies.co.za/displaythumb.zip)
   for you.
 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640457)
 * The thumbnail it generates uses imagewidth to work out height, as it resizes 
   proportionally.
 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640458)
 * You can see the result more clearly here:
 * 150px Wide View
    ——————————————-
 * [http://www.estateagencies.co.za/demo/displaythumb.php?imagewidth=150&photoid=1234.jpg](http://www.estateagencies.co.za/demo/displaythumb.php?imagewidth=150&photoid=1234.jpg)
 * 550px Wide View
 * ——————————————–
 * [http://www.estateagencies.co.za/demo/displaythumb.php?imagewidth=550&photoid=1234.jpg](http://www.estateagencies.co.za/demo/displaythumb.php?imagewidth=550&photoid=1234.jpg)
 *  Thread Starter [fouadovic](https://wordpress.org/support/users/fouadovic/)
 * (@fouadovic)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640459)
 * I will see if i can use this script.
    I will reply soon. Thanks a lot taz72.
 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640460)
 * My Pleasure 🙂
 *  Thread Starter [fouadovic](https://wordpress.org/support/users/fouadovic/)
 * (@fouadovic)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640463)
 * taz72,
    In WP, where is the link to the image? Where i have to put this : <img
   src=”displaythumb.php?imagewidth=450&photoid=1234.jpg”> ? In single.php, we have
   the function “the_content” taht display all the post. Thanks
 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640464)
 * Are you uploading the image via WordPress, or are you referencing to it via an
   <img> call?
 * You should be able to upload the image using WordPress Upload, but do not insert
   it into the post as a thumbnail or anything. Once the upload is complete, in 
   your post, you can call the image like such :
 * <img src=”[http://www.yourwebsite.com/wp-content/uploads/displaythumb.php?imagewidth=150&photoid=yourimage.jpg”&gt](http://www.yourwebsite.com/wp-content/uploads/displaythumb.php?imagewidth=150&photoid=yourimage.jpg”&gt);
 * This should work quite fine 🙂
 * I will do a test for you kwik, then send you the link and the post so u can see.
 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640465)
 * If you have a look at [http://e-complaints.co.za](http://e-complaints.co.za) 
   I have published a test JPG using displaythumb.php
 * I wrote a post, uploaded the full size JPG using WordPress but noted that wordpress
   creates a directory structure in /uploads so I had to modify the file structure
   a bit.
 * The displaythumb.php file now looks like this:
 * <?php
 * $thumbname = $_GET[photoid];
    $directory = “/home/complain/public_html/wp-content/
   uploads/2007/10”; $widthimage = $_GET[imagewidth]; $filename = $directory . ‘/’.
   $thumbname; $max = $_GET[max]; //$filename = $thumbname; $new_h = $widthimage;//
   Content type header(‘Content-type: image/jpeg’); // Get new sizes $src_img = 
   imagecreatefromjpeg($filename); $origw=imagesx($src_img); $origh=imagesy($src_img);
   $ratio=$origw*$new_h; $new_w=$ratio/$origh; $dst_img = imagecreatetruecolor($
   new_w,$new_h); imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx(
   $src_img),imagesy($src_img)); imagejpeg($dst_img);
 * ?>
 * I hope this was helpful
 *  Thread Starter [fouadovic](https://wordpress.org/support/users/fouadovic/)
 * (@fouadovic)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640466)
 * I upload with WP.
    I try to make writing and uploading image easier, it’s for
   a friend who will work with WP, he has not the experience to do this correctly.
   So, if he works in the admin area he must not send image in the text zone? he
   will just upload image, that’s right?
 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640467)
 * Yes.. He can upload using WordPress, but not click “Send to Editor”.. Instead
   he will need to click on the Post’s Code View, then Click the [img] button, and
   place the URL to the image.
 * Like :
 * [http://www.yoursite.com/wp-content/uploads/2007/10/displaythumb.php?imagewidth=150&photoid=yourpic.jpg](http://www.yoursite.com/wp-content/uploads/2007/10/displaythumb.php?imagewidth=150&photoid=yourpic.jpg)
 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640468)
 * I would recommend he keeps a URL snippet handy so he does not have to retype 
   the URL all the time though.
 * I am using a database and PHP to generate my property listings automatically,
   so for me it is easier. I do not have to type anything in, it’s all automated.
 *  Thread Starter [fouadovic](https://wordpress.org/support/users/fouadovic/)
 * (@fouadovic)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640469)
 * I don’t think that will be easy for him.
    I thought there will be a solution 
   with the **upload form** (in the “writhe post” page). When you upload the image,
   the size is edited (usign GD lib i think). Do you have an idea using this? Thanks
 *  [taz72](https://wordpress.org/support/users/taz72/)
 * (@taz72)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/#post-640470)
 * Sorry 🙁 My knowledge is slightly limited in that area, but I would say the best
   would be to modify the WordPress source to do this for you.

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/re-size-image-automatically/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/re-size-image-automatically/page/2/?output_format=md)

The topic ‘Re-size image automatically’ is closed to new replies.

 * 19 replies
 * 3 participants
 * Last reply from: [fouadovic](https://wordpress.org/support/users/fouadovic/)
 * Last activity: [18 years, 7 months ago](https://wordpress.org/support/topic/re-size-image-automatically/page/2/#post-640667)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
