473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Displaying 'image deleted' image if an image was deleted.

Markus
6,050 Expert 4TB
Haha. The title makes me chuckle..

Anyway..

I've seen on numerous, large image hosting websites an image be displayed if the image, say, 'broke the TOS' or the image was deleted or the image can not be found.

I was just wondering how they went about this..
because i find it strange how they can replace an image, that's hosted on their server but embeded on a different website - If you understand me?

Thanks for your time and merry christmas :)

markus
Dec 22 '07 #1
6 1825
pbmods
5,821 Expert 4TB
Heya, Markus.

So you're saying that you want to link to an image on a different server, but if the image meets certain criteria (say the URL is known to point to a 'naughty' image), then the image is not displayed; is that correct?
Dec 22 '07 #2
Markus
6,050 Expert 4TB
Heya, Markus.

So you're saying that you want to link to an image on a different server, but if the image meets certain criteria (say the URL is known to point to a 'naughty' image), then the image is not displayed; is that correct?
That's correct.

Let me explain it a little more.

Say i have an image hosting site. Images are uploaded, URLs stored in database and images stored on the server. If an image was to be deleted, by me or whomever, but the image was still hotlinked to on say myspace, it would show an "image-deleted" image.

p.s.
Why do you write out variables like so?:
[php]
$__variable;
[/php]

thanks :)
Dec 22 '07 #3
pbmods
5,821 Expert 4TB
Heya, Markus.

I'll answer your second question first. The double underscore is used when I know that a variable is "safe". In other words:

Expand|Select|Wrap|Line Numbers
  1. $__i = 0;
  2.  
I know that I declared $__i somewhere in my code, and I know its value.

On the other hand:

Expand|Select|Wrap|Line Numbers
  1. function doSomething( $param )
  2.  
When I use $param in my function, I know that I did not explicitly set the value, and I'm not 100% sure of its contents.

Generally, when I "safe" User input, I will prepend a single underscore. E.g.:
Expand|Select|Wrap|Line Numbers
  1. $_userID = (int) $userID;
  2.  
The idea here is to never use 'unsafe' variables for sensitive operations. For example, I will never do this:

Expand|Select|Wrap|Line Numbers
  1. $__sql = "SELECT * FROM `table` WHERE `id` = '{$id}' LIMIT 1";
  2.  
Instead, I will do this:
Expand|Select|Wrap|Line Numbers
  1. $_id = (int) $id;
  2. $__sql = "SELECT * FROM `table` WHERE `id` = '{$_id}' LIMIT 1";
  3.  
Now then.

My suggestion for your problem would be to create a showimage.php (or similarly-named script).

This file would take a URL as a parameter and output either the image data (don't forget to set the Content-Type header) or else a generic 'File Not Found' (or 'Deleted', etc.) image.

Something like this:
Expand|Select|Wrap|Line Numbers
  1. if( isset($_GET['image']) )
  2. {
  3.     $imageData = loadImageFromDatabase($_GET['image']);
  4. }
  5.  
  6. if( empty($imageData) )
  7. {
  8.     $imageData =
  9.         array
  10.         (
  11.             'path' => 'path/to/not/found.jpg',
  12.             'type' => 'image/jpeg'
  13.         );
  14. }
  15.  
  16. header("Content-Type: {$imageData['type']}");
  17. readfile('/path/to/images/' . basename($imageData['path']));
  18.  
The loadImageFromDatabase() function would look up the image in the database and return an empty array if the image was not found / deleted / etc.
Dec 23 '07 #4
Markus
6,050 Expert 4TB
I'm not sure whether i got my point across or i don't fully understand your solution.

My thought is that the image which has been uploaded, given out a direct img url which the user can then take and embed onto their myspace page. If the image was deleted then the direct url on the myspace page would not display an image. But i've seen hosters change the image with a default one.

I'm sorry about this - i'm finding it hard to explain.

And i love the ideology behind the 'safe' variables.
Dec 23 '07 #5
pbmods
5,821 Expert 4TB
Heya, Markus.

You could set up a 404 for the images directory that serves a 'file not found' image:

Put a .htaccess file in your images directory:
Expand|Select|Wrap|Line Numbers
  1. ErrorDocument 404 filenotfound.jpg
  2.  
Dec 23 '07 #6
Markus
6,050 Expert 4TB
Heya, Markus.

You could set up a 404 for the images directory that serves a 'file not found' image:

Put a .htaccess file in your images directory:
Expand|Select|Wrap|Line Numbers
  1. ErrorDocument 404 filenotfound.jpg
  2.  
Thankyou very much pb.

:)
Dec 23 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ralph Freshour | last post by:
My .php app displays an image on the web page, I notice that different ..jpg images display "funny" - apparently they all have slightly different image widths and heights yet in the image tag I...
3
by: Dalan | last post by:
At first I was not certain what could cause Access 97 from displaying most jpeg images, but not all. After further testing, it seemed that all original images of less than 275 pixels per inch or...
7
by: Joe | last post by:
I am using Access 2003 and are linking to an Oracle 9i ODBC datasource (using Oracle ODBC drivers). After linking the tables in Access, I inspect the data contained in the linked tables. For...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
1
by: David Lozzi | last post by:
Hello, I'm wondering whats the best method to use for displaying several photos' thumbnails. One method I know is to dynamically resize the photo at the time the page is loaded. What does this...
6
by: Mark Denardo | last post by:
I created a Web Image "<asp:Image ID="Image1" ..." that my code behind set to a certain image file say image1.jpg =Image1.ImageUrl = "<rel_path>/image1.jpg"; which set the image ok, but then I...
4
by: redpears007 | last post by:
Hi Again, Throwing this one out to you again as i am not getting anywhere and can find little to no information out there. I am currently displaying images (Jpegs) in access via the routine...
4
by: shahidrasul | last post by:
i display a pic on picture box and then i want to display another pic after some seconds but problem is that first image is not displaying only display 2nd image 1... display first picture from...
3
by: mvijayrkumar | last post by:
Hi to all.... Guys pls help me..... I have an image issue in RLDC while hosting my project on server.The image displays or works fine with the local system.But when hosted on server,both the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.