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?
Asked
Active
Viewed 346 times
1 Answers
0
- You'll need to use cURL.
- To download images with cURL, you can modify this example to suit your needs.
- 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.
- To "parse" HTML and make sense of it (with PHP), you can use DOMDocument.
- 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