Bangalore Posted December 13, 2012 Report Share Posted December 13, 2012 Does anyone know how to show a default image if no file/image exists? Quote Link to comment Share on other sites More sharing options...
MayMusic Posted December 13, 2012 Report Share Posted December 13, 2012 On your details page there is an option to show a default image if you display your file as image. But if you do not have a file field to display your image and you only have the link to the image then you need to have an extra line of the code to check and see if the URL is blank then use a default URL. I have sample of the code, you are welcome to borrow it: <script> var image = '[@field:file1]'; if (image != "") { document.write("[@field:file1]'>"); } </script> Make sure to replace file1 with your file field ID and also replace DefaultImageURL with URL of the image you would like to have as default. Quote Link to comment Share on other sites More sharing options...
Bangalore Posted December 13, 2012 Author Report Share Posted December 13, 2012 Thank you May Music Quote Link to comment Share on other sites More sharing options...
Bangalore Posted December 13, 2012 Author Report Share Posted December 13, 2012 How can I make this image clickable, and show a large image? Quote Link to comment Share on other sites More sharing options...
MayMusic Posted December 13, 2012 Report Share Posted December 13, 2012 Well you can try this: <script type="text/javascript"> var image= '[@field:file1]'; if (image != "") { document.write("file1]','popup','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=750,height=600'))\">"); } else { document.write("URL','popup','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=750,height=600'))\">DefaultImageURL\" alt=\"Default\" />"); } </script> URL is the URL of the large image in here. Quote Link to comment Share on other sites More sharing options...
Bangalore Posted December 13, 2012 Author Report Share Posted December 13, 2012 May Music, You are so prompt Thank you Will try this out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.