URL Image Getter/Uploader/Resizer

I was wondering how to get images from a site the same way like Digg or Facebook do, where it is only necessary to provide a link, and images get […]

I was wondering how to get images from a site the same way like Digg or Facebook do, where it is only necessary to provide a link, and images get automatically uploaded to your server and resized. So, I decided to create a script that does exactly that and share it here.

This PHP script uses two php classes that I found on the web. One of them I have already used before in the “jQuery Image Cropper with Uploader” and the “Dynamic jQuery Image Gallery with Uploader“, the class.upload from verot . The other is a PHP html DOM Parser that can be found here.

In order to make this work, I had to change some few lines of code in verot’s class, so that URLs can be used to get images.  The DOM Parser is untouched. I also created a file (index.php) where both scripts are called. I first parse the URL, search for images and pass the url of the image to the class.upload script, which then uploads the image to a local directory (images/) and resizes it. In this script, the image size is changed to a width of 150 pixels but the ratio is kept. However, you can change these values and configure it the way you want. Take a look at the documentation of the class.upload so that you know what you can change. Also, you can specify how many images you want to save / display per request.

Tiny break: 📬 Want to stay up to date with frontend and trends in web design? Subscribe and get our Collective newsletter twice a tweek.

For the demo (not available anymore, sorry!) which has this blog as “target”, I have configured that only a restricted amount of images are saved and shown. Besides, you might notice that sometimes it displays more images than other times. This is caused by the limited amount of memory configured in the php.ini file (memory_limit), so you might wanna change this value to a proper one if you want to use this script. Again, on verot’s web site, in the forums,  there are some good calculations giving an idea of a suitable value.

Download source

chadking

Chadking is an absolute geek that rarely leaves the comfort of his 3-screen desk. He is a self taught programmer and is addicted to all possible legal drugs.

Stay in the loop: Get your dose of frontend twice a week

👾 Hey! Looking for the latest in frontend? Twice a week, we'll deliver the freshest frontend news, website inspo, cool code demos, videos and UI animations right to your inbox.

Zero fluff, all quality, to make your Mondays and Thursdays more creative!

Feedback 7

Comments are closed.
  1. Pingback: URL Image Getter/Uploader/Resizer | Codrops Search Engine Marketing

  2. Pingback: uberVU - social comments

  3. Pingback: Most Tweeted Articles by E-Commerce Experts

    • Thanks James. There’s seems to be a problem since you visited the page! What have you done? Just joking, I will take a look and fix it soon.
      Cheers