Having a default image for an image cropper if the user doesnt submit image
I am using an image cropper for news thumbnails on my website but i want to provide a default image if the user doesn't have a suitable image for the particular news article.
I tried an if statement checking if the image cropper is null but it didn't work.
What did the code you're trying to use look like? And what happened? Did you get an error or?
You're on the right track but perhaps you hit a syntax error or your check never does anything etc. - So please share the code you tried to get working and let's take it from there :)
When you write it returns a value for one of the items I'm getting a bit confused - What does it return for other items? We're not interested in those that have an image - Those that don't do we want to know what they return if anything like "Null" or just an empty string.
The null check you do in your code currently obviously does not work so perhaps you need to check for both null and empty strings for instance :)
Having a default image for an image cropper if the user doesnt submit image
I am using an image cropper for news thumbnails on my website but i want to provide a default image if the user doesn't have a suitable image for the particular news article.
I tried an if statement checking if the image cropper is null but it didn't work.
Any help would be great.
Kind Regards,
Gary
Hi Gary
What did the code you're trying to use look like? And what happened? Did you get an error or?
You're on the right track but perhaps you hit a syntax error or your check never does anything etc. - So please share the code you tried to get working and let's take it from there :)
/Jan
This uses the static image in the else statement. Can you see where im going wrong? Any help would be appreciated.
Kind Regards,
Gary
Hi Gary
Ok, so I'm wondering if the thumbnail crop does not exist whether you're actually getting null back or whether the value is perhaps just empty.
What do you get if you try to just render? Does it return a value or does it result in an error message?
/Jan
Hi Again Jan,
Returns This for one of the items:
so there is a value. Is there a better way to check the value or existence of an image inside the image cropper?
Cheers,
Gary
Hi Gary
When you write it returns a value for one of the items I'm getting a bit confused - What does it return for other items? We're not interested in those that have an image - Those that don't do we want to know what they return if anything like "Null" or just an empty string.
The null check you do in your code currently obviously does not work so perhaps you need to check for both null and empty strings for instance :)
/Jan
I have the answer..
Gives me exactly what i want.
Thank you for your patience with this and your help :) !
Kind Regards,
Gary
is working on a reply...