How to use your own customized No Image File
Sometimes it is neccessary to be able to customize your web site so that you will not show the generic NO IMAGE picture that we deliver for missing product images.
Example usage would be to display your web site logo instead.
This technique applies to all our image deliveries such as Products with SKU, Merchant Products and Merchant Logos
There are a couple ways of subtituting for your own Alternate No Image Picture:
- Adding &alt GET variable behind the image URL. (easy)
- Detecting broken image from your own script and delivering your own image. (difficult)
Adding &alt GET variable behind current image URL
We have created support for alternate image to be displayed only if the real image is not found.
Here is how you use it:
For product with SKU:
http://df9.us/c?c=123456&alt=http://www.idecorbook.com/noimage.gif
note the &alt= GET variable behind the URL above
similarly for product without SKU (using mernum + mersku + prdtid):
http://mimages.datafeedfile.com/images/merprdtimg80x80id.php?mernum=...&mersku=...&prdtid=...&alt=......
Detecting Broken Image and Delivering your own
<?php
// DFF_custom_noimg.php
//
// DETECT DFF_PRODUCT SKU IMAGE AVAILABILITY.
// IF AVAIL, OUTPUTS THE ACTUAL IMAGE FROM DFF.
// IF NOT AVAIL, OUTPUT YOUR OWN CUSTOM NO IMAGE FILE
//
// Usage:
// 1. You need to create your own custom 80x80 no image file (gif/jpeg/png)
// 2. You need to specify your own unique etag (entity tag) identifier:
// etag can be any alphanumeric (no space), preferably less than 30 characters.
// Using your abreviated site name like: womenaweekshopping is good enough.
// 3. Specify both $your_custom_noimg_pathfile and $your_etag variables values.
// 4. place this PHP file in your PHP web server and point the SRC of IMG tag to this file with sku=<<<DFF_SKU>>> query string parameter.
//
// Example:
// <img src="DFF_custom_noimg.php?sku=_________">
//
// DFF PREDEFINED VARIABLE
$DFF_img_url =
'http://df9.us/c?c=';
// SKU $_GET VARIABLE
$DFF_SKU =
FALSE;
if($_GET['sku']!=
'') $DFF_SKU =
intval($_GET['sku']);
if($DFF_SKU==
FALSE &&
$_GET['dff_sku']!=
'') $DFF_SKU =
intval($_GET['dff_sku']);
if($DFF_SKU==
FALSE) die('Need to specify sku # into GET query string / URL');
// VARIABLES YOUR NEED TO CUSTOMIZE
$your_custom_noimg_pathfile =
'/path/to/your/noimage.gif';
$your_etag =
'mysitecode_noimg80';
$image_content =
file_get_contents($DFF_img_url.
$DFF_SKU);
$response_headers =
$http_response_header;
//echo "<pre>".print_r($response_headers,TRUE)."</pre><br>"; exit;
if(strpos($response_headers[15],
'dff-noimg')!==
FALSE){
// SHOW YOUR CUSTOM NO IMAGE FILE HERE (80x80 pixels)
$noimg_filesize = @
filesize($your_custom_noimg_pathfile);
$noimg_filedate = @
filemtime($your_custom_noimg_pathfile);
if($noimg_filesize==
FALSE ||
$noimg_filedate==
FALSE) die('Invalid custom no image file.');
$request_headers =
apache_request_headers();
if((strpos($request_headers['If-None-Match'],
$your_etag)) &&
(gmstrftime("%a, %d %b %Y %T %Z",
$noimg_filedate) ==
$request_headers['If-Modified-Since'])){
//STILL THE SAME - USE CACHE
header('HTTP/1.1 304 Not Modified');
header('Cache-Control:private');
header('Pragma:');
header('Expires:');
header('Content-Type:');
header('ETag:"'.
$your_etag.
'"');
} else {
header('Content-Type: image/jpeg');
header('Content-Transfer-Encoding: binary');
header('Content-Length:'.
$noimg_filesize);
header('Cache-Control:private');
header('Pragma:');
header('Expires:'.
gmdate('D, d M Y H:i:s',
time() +
30240000).
' GMT');
header('Last-Modified:'.
gmdate('D, d M Y H:i:s',
$noimg_filedate).
' GMT');
header('ETag:"'.
$your_etag.
'"');
readfile($your_custom_noimg_pathfile);
}
exit;
} else {
// IMAGE EXISTS - DELIVER DFF'S PRODUCT IMAGE
for($i=
0;
$i<count
($response_headers);
$i++
) if(strpos($response_headers[$i],
'200 OK')!==
FALSE) break;
for(;
$i<count
($response_headers);
$i++
){
header($response_headers[$i]);
echo $image_content;
}
}
?>
There are no comments on this page. [Add comment]