Jump to content

alternative image


The Little Guy

Recommended Posts

All images are ported to a central file, images.php  via .htaccess

 

From there they use the url to determine if the file exists, if not the images.php prints out the generic 404 for images. If it does it goes and retrieves the file and print that out instead.

Link to comment
Share on other sites

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.jpg$ images.php [nc]

 

Will that still work, even if the images are being displayed on a foum? or on some other website?

 

Should it takes any request and routes it through images.php

Link to comment
Share on other sites

so... if I have this:

 

<?php

if(!file_exists($_GET['filename']))
echo '<img src="http://tzfiles.com/imageNotFound.jpg">';
else
echo '<img src="'.$_GET['filename'].'">';

?>

 

 

Would I place it like this:

 

<?php
readfile('imageNotFound.jpg');
header('Content-type: images/jpeg');
if(!file_exists($_GET['filename']))
echo '<img src="http://tzfiles.com/imageNotFound.jpg">';
else
echo '<img src="'.$_GET['filename'].'">';

?>

Link to comment
Share on other sites

<?php
header('Content-type: images/jpeg');
if(!file_exists($_GET['filename']))
readfile("http://tzfiles.com/imageNotFound.jpg");
else
readfile($_GET['filename']);

?>

 

In order for it to be interpreted as an image it must be read and written to the browser as an image. The img src is part of html, which is not part of an image file.

Link to comment
Share on other sites

Implement some debugging standards.

 

What is the filename printing out? Is it printing out the full path or not?

 

You should probably add the full path to it, as the .htaccess rewrite changes the directory to be where the images.php file is.

 

So even though the url is pointing to /images/etc.jpg the relative path would be /image.php so you would then need to add that into the get string.

 

The script will work like it is suppose to, you just have to have the full path to the file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.