-2

I'm trying to use an <img> tag to display a webpage as a thumbnail. I would like the front page of the site to basically be a thumbnail image.

So for example, if I have google.com I'd like to convert the front page to an image and then do something like this:

<?php
$url = 'http://google.com';
//make this an image some how
echo '<img src="$url_image">';

Does anyone have an idea how to do this?

Zoe
  • 27,060
  • 21
  • 118
  • 148
user1048676
  • 9,756
  • 26
  • 83
  • 120
  • You'd have to screenshot the page, save it to your server, then serve that. http://stackoverflow.com/questions/757675/website-screenshots-using-php – chris85 Apr 01 '15 at 01:19
  • Any chance of building it on the fly instead of saving it to the server? I saw that one but don't necessarily want to save it if I don't have to. – user1048676 Apr 01 '15 at 01:20
  • You'd want to use something like [imagecreatefromjpeg](http://php.net/manual/en/function.imagecreatefromjpeg.php) with @chris85 comment to do this on the fly. – Adam Link Apr 01 '15 at 01:22

1 Answers1

2

As an alternative, you could use thumbalizr for this also:

<?php
$url = 'http://www.google.com';
$api = "http://api.thumbalizr.com/?url={$url}&width=250";
echo "<img src='{$api}' alt='thumbnail site' />";
?>

Sidenote: It will show a watermark.

Out

Kevin
  • 41,694
  • 12
  • 53
  • 70