Keyword

Display "coming-soon" image when no image is uploaded

  • Nick
  • Nick's Avatar Topic Author
  • Offline
  • Elite Member
More
13 years 8 months ago #92096 by Nick
I took it upon myself to display a standard image when no image has been uploaded. Personally I am using this for some automation since I am inserting data into the DB automagically and the image has to be added later on. So for people who are seeking this functionality: open up your item.php file from your template (or wherever you have it stored) and search for this line:



(obviously every [ ] is a carrot sign but ning is being gay)

should be around line 200. This is where the code for the image is initialized. Now as you can see the php tag checks if the image is NOT empty (with the !). If it is NOT empty it executes the code under it. What we want to do is put another check in between



[?php echo $this->item->event->K2BeforeDisplayContent; ?]

and

[?php if($this->item->params->get('itemImage') && !empty($this->item->image)): ?]


Paste the attached code between those 2 bits of code.. basically replacing the "and"

Now we want to do the same for the category_item.php and it's almost the identical process.

open that file up and go to around line 110. Again look for those 2 pieces of code that i have above (they are the almost the same in both files)

Add between them the attached code!

Save and you're done! BTW.. you OBVIOUSLY need to have a coming soon image stored in your images folder or wherever. Currently it's set to /images/coming-soon.jpg and /images/coming-soon-s.jpg (for the small version)

You will need to create the images in the same size as whatever sizes you are using for those two display modes. I don't know what will happen if you don't... If it doesn't work just replace

[?php echo $this->item->imageWidth; ?]

by a NUMERICAL value in both files (270 for example)

Hope this helps out people!
Attachments:

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum