Hello,
I've installed JPDeni's File Upload recently, and using it to display images users upload in both their short & long listings (I installed the short/long record display mod, too). I was trying to find a way to automatically display a default image (or text) which says "Image Not Available" if the user has not uploaded an image to go along with her or her listing. I've tried a few different things, with limited success.
Here is the code I have right now:
|; # to close off a previous print qq| statement
$ALLOWED_EXT =~ s/\\.//g;
$ALLOWED_EXT =~ s/\$//g;
@extensions = split (/\Q|\E/o,$ALLOWED_EXT);
GRAPHIC: foreach $extension (@extensions) {
if (-e "$SAVE_DIRECTORY/$rec{$db_key}.$extension") {
print qq|
<img src="$SAVE_DIRECTORY_URL/$rec{$db_key}.$extension">
|;
last GRAPHIC;
}
}
print qq|
I tried modifying the "if" statement to:
if (-e "$SAVE_DIRECTORY/$rec{$db_key}.$extension") {
print qq|
<img src="$SAVE_DIRECTORY_URL/$rec{$db_key}.$extension">
|;
last GRAPHIC;
}
else {
printqq|
Image Not Available
|;
}
And I've also tried an elsif statement like this:
elsif (!-e "$SAVE_DIRECTORY/$rec{$db_key}.$extension") {
printqq|
Image Not Available
|;
And I even tried closing the first "if" statement and starting a new "if" statement with the same code as the "elsif" statement above, but none of these things worked. In the course of my trial and error, I sometimes received the default "Image Not Available" message in all of the listings, including those which did have images available, and other times I received the default "Image Not Available" message in the listings with no images, and the "Image Not Available" message PLUS the image, for listings with images available. And in other cases yet, I received a double "Image Not Available" message in the listings with no images, and an image and the "Image Not Available" message in listings with an image available.
I'm not really a perl programmer and am just making guesses as to how this mod should be written (without much success). Can anyone help me by showing me how this is supposed to be written?
Many thanks in advance,
Peter
I've installed JPDeni's File Upload recently, and using it to display images users upload in both their short & long listings (I installed the short/long record display mod, too). I was trying to find a way to automatically display a default image (or text) which says "Image Not Available" if the user has not uploaded an image to go along with her or her listing. I've tried a few different things, with limited success.
Here is the code I have right now:
|; # to close off a previous print qq| statement
$ALLOWED_EXT =~ s/\\.//g;
$ALLOWED_EXT =~ s/\$//g;
@extensions = split (/\Q|\E/o,$ALLOWED_EXT);
GRAPHIC: foreach $extension (@extensions) {
if (-e "$SAVE_DIRECTORY/$rec{$db_key}.$extension") {
print qq|
<img src="$SAVE_DIRECTORY_URL/$rec{$db_key}.$extension">
|;
last GRAPHIC;
}
}
print qq|
I tried modifying the "if" statement to:
if (-e "$SAVE_DIRECTORY/$rec{$db_key}.$extension") {
print qq|
<img src="$SAVE_DIRECTORY_URL/$rec{$db_key}.$extension">
|;
last GRAPHIC;
}
else {
printqq|
Image Not Available
|;
}
And I've also tried an elsif statement like this:
elsif (!-e "$SAVE_DIRECTORY/$rec{$db_key}.$extension") {
printqq|
Image Not Available
|;
And I even tried closing the first "if" statement and starting a new "if" statement with the same code as the "elsif" statement above, but none of these things worked. In the course of my trial and error, I sometimes received the default "Image Not Available" message in all of the listings, including those which did have images available, and other times I received the default "Image Not Available" message in the listings with no images, and the "Image Not Available" message PLUS the image, for listings with images available. And in other cases yet, I received a double "Image Not Available" message in the listings with no images, and an image and the "Image Not Available" message in listings with an image available.
I'm not really a perl programmer and am just making guesses as to how this mod should be written (without much success). Can anyone help me by showing me how this is supposed to be written?
Many thanks in advance,
Peter