-5

I am hoping to create a link submission page similar to that of Reddit's where I can show the thumbnail of a given URL without reloading the page. What would be the best way to do this and are there any examples?

Corbin
  • 33,060
  • 6
  • 68
  • 78
  • There was a good article on this but I can't find it. Here's something related http://www.99points.info/2010/07/facebook-like-extracting-url-data-with-jquery-ajax-php/ – Waleed Khan Dec 23 '12 at 22:31

1 Answers1

0
  1. You'll need to use cURL.
  2. To download images with cURL, you can modify this example to suit your needs.
  3. You'll need to come up with an algorithm that will choose the most "interesting" image. This is because a lot of pages will have multiple images. If you're lazy or if it's not a major issue, you could simply choose the first image in the document.
  4. To "parse" HTML and make sense of it (with PHP), you can use DOMDocument.
  5. Once you download the image, you should crop it, save the cropped version and then get rid of the original (FAR better than simply saving and re-sizing the original on the fly).

Using cURL and DOMDocument together, you should be able to put something together.

Community
  • 1
  • 1
Wayne Whitty
  • 19,513
  • 7
  • 44
  • 66