PHP Classes

How to embed into HTML?

Recommend this page to a friend!

      phpThumbnailer  >  All threads  >  How to embed into HTML?  >  (Un) Subscribe thread alerts  
Subject:How to embed into HTML?
Summary:I receive "header"error when I call class from within HTML/PHP
Messages:3
Author:BC
Date:2006-09-05 19:04:42
Update:2006-09-06 00:03:03
 

  1. How to embed into HTML?   Reply   Report abuse  
Picture of BC BC - 2006-09-05 19:04:42
I am trying to call this class from within my HTML page and receive this error:

"Warning: Cannot modify header information - headers already sent by..."

The line it points to is the 'header("Content-type: image/jpeg")' line in the class.Thumbnail.php file.

I am trying to display a list of images in a directory and want to use the phpThumbnailer to display a thumbnail of each image in the list.

My file looks roughly like this:
<HTML>
<BODY>
<?php
Loop through files in folder
For each file: display thumbnail (i.e. call Thumbnail function)
?>
</BODY>
<HTML>

Any ideas?

Thanks,
BC

  2. Re: How to embed into HTML?   Reply   Report abuse  
Picture of Matt Matt - 2006-09-05 21:06:54 - In reply to message 1 from BC
You are misunderstanding how the thumbnail function works.

The image functions output binary data rather than anything that can be embedded into HTML, so you have to put your thumbnail script in another file (say, thumbnail.php for example). You can then "put" the image in the file by using the <img src="thumbnail.php"> call.

In your case, since you are iterating through a folder, I would suggest you change your script to look more like this:

<html>
<head>
...
</head>
<body>
...
<?
... iterate through all files and folders here.
echo "<img src='thumbnail.php?file=". $TheCurrentFile ."'>";
...
?>
</body>
</html>



Your Thumbnail.php file will then look like this:

<?php

$TheFile = $_GET["file"];

// thumbnail generation script here.

?>

  3. Re: How to embed into HTML?   Reply   Report abuse  
Picture of BC BC - 2006-09-06 00:03:03 - In reply to message 2 from Matt
Ahh...that makes sense.

I definitely misinterpreted the functionality.

I'll give your solution a try.

Many thanks,
BC