Script feature problem
Posted by: camdon
Posted on: 2005-06-20 21:09:00
Hello all. I've been trying since April to get one option of a script I use on my site working to no avail. It worked before Dreamhost turned off allow_url_fopen. The section I'm having trouble with is suppose to check the image and if it doesn't meet certain criteria then replace it with my custom replacement image. Here is the section I need help with. I've tried using and customizing all three option (not at the same time). Help!! My brain hurts!
$IncAlbum = 0;
switch ($AlbumImageSize) {
case 'Small':
$ProductImage = $Result[0]['ImageUrlSmall'];
if (strlen(file_get_contents($ProductImage)) < 808 ) {
$ProductImage = $MissingAlbumImageSmall;
}
while (($IncAlbum) < $TotalAlbumOverrides) {
$CurrentAlbum = explode( '||', $AlbumCoverOverrideList[$IncAlbum] );
if ( ($CurrentAlbum[0] == $Artist) && ( $CurrentAlbum[1] == $Album) ){
$ProductImage = $CurrentAlbum[2];
break;
}
$IncAlbum++;
}
break;
case 'Medium':
$ProductImage = $Result[0]['ImageUrlMedium'];
if (strlen(file_get_contents($ProductImage)) < 808 ) {
$ProductImage = $MissingAlbumImageMedium;
}
while (($IncAlbum) < $TotalAlbumOverrides) {
$CurrentAlbum = explode( '||', $AlbumCoverOverrideList[$IncAlbum] );
if ( ($CurrentAlbum[0] == $Artist) && ( $CurrentAlbum[1] == $Album) ){
$ProductImage = $CurrentAlbum[3];
break;
}
$IncAlbum++;
}
break;
case 'Large':
$ProductImage = $Result[0]['ImageUrlLarge'];
if (strlen(file_get_contents($ProductImage)) < 808 ) {
$ProductImage = $MissingAlbumImageLarge;
}
while (($IncAlbum) < $TotalAlbumOverrides) {
$CurrentAlbum = explode( '||', $AlbumCoverOverrideList[$IncAlbum] );
if ( ($CurrentAlbum[0] == $Artist) && ( $CurrentAlbum[1] == $Album) ){
$ProductImage = $CurrentAlbum[4];
break;
}
$IncAlbum++;
}
break;
default:
$ProductImage = $Result[0]['$ImageUrlSmall'];
if (strlen(file_get_contents($ProductImage)) < 808 ) {
$ProductImage = $MissingAlbumImageSmall;
}
while (($IncAlbum) < $TotalAlbumOverrides) {
$CurrentAlbum = explode( '||', $AlbumCoverOverrideList[$IncAlbum] );
if ( ($CurrentAlbum[0] == $Artist) && ( $CurrentAlbum[1] == $Album) ){
$ProductImage = $CurrentAlbum[2];
break;
}
$IncAlbum++;
}
}
/* Alternate (unused) broken-image detection methods
// Open the product image and read the first three bytes to
// determine if the file is a GIF - Amazon uses a single pixel
GIF for items that do not have an image
$handle = fopen($ProductImage, "r");
$contents = fread($handle, 3);
fclose($handle);
if ($contents == 'GIF' ){
$ProductImage = $MissingAlbumImage;
}
// Or use PHP's GetImageSize
$ProductImageSize = getimagesize($ProductImage);
$ProductImageWidth = $ProductImageSize[0];
if ($ProductImage == '' || $ProductImageWidth < 45){
$ProductImage = $MissingAlbumImage;
}
*/