I tried it but if I put a header request in a page it overrites the entire page as just the image.
That is:
<html>
<h1>Hi there</h1>
<?php
$image = fread(...bunch of stuff...);
header("Content-Type: $type");
echo $image;
?>
Now how was that.
</html> doesn't render as:
<html>
<h1>Hi there</h1>
<?php
{image}
Now how was that.
</html>
[/code]
as I'd like it too. The header() starts a whole new page so all I get is the image as an image file.
<img src="file"> is "shorthand" (sorta, though not really) for "Make a request indicated by the name and put the returned content here". My problem is I have no source name and I already now the content right here.
So far as I know there is no way to manipulate HTML to give the content tag the content directly.
We can't to <img content="@jfkui$_$mpv...bunch of binary code kilobytes in length"> nor can we use PHP to do something like <img src="<? temp_file(header('content'), content($image))?>"> where temp_file() is some place holder for a non-existant file whose content is "$image".
I tried doing:
first_page.php::
<image src="image.php?type=<?= $photo_type ?>&content=<?= $image ?>">
image.php::
$image = $_GET['content'];
$type = $_GET['type'];
header("Content-type: $type");
echo $image; This is impractical as GET variables have limits to length and here we have a GET variable whose value could be megabytes big.
I'm thinking I could do it by POST but am not sure how to call it.
What I'm hoping I can do is something like:
echo "<h1>Hi there</h1>"
echo-image ($image, $type, "left");
where echo-image($content, $image_type, $alignment, ... other img attributes) will somehow cough up the image content into an image on the page.
<img> is an http request. The browser fills in with the content of the response. Is there PHP code that can allow me skip the request but request that a response of my programming (it would be "Content-type: $type\n\n$image") be filled in?