- Posts: 14
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- Automatically add a picture when ignoring the "Choose a image" in the add an item form
Automatically add a picture when ignoring the "Choose a image" in the add an item form
- Ante Oja
-
Topic Author
- Offline
- New Member
Less
More
14 years 1 month ago #95295
by Ante Oja
Automatically add a picture when ignoring the "Choose a image" in the add an item form was created by Ante Oja
Hello! I'm new to the forum so I hope I've posted right, otherwise MOD please move the thread .Please excuse my bad English. I wonder if it is possible that if you skip to set an image to the item (in adding an item) so that another image that I made comes up. Where it says for example "No image" or something similar.But if I choose a picture to an Item it shows the choosen image instead of the "no image" image.
At the moment it looks like this ->
And i want it to be like this when I do not choose a picture to the item.<-
I really hope that someone of you understand my question!
Thanks in advance! :)
At the moment it looks like this ->
And i want it to be like this when I do not choose a picture to the item.<-
I really hope that someone of you understand my question!
Thanks in advance! :)
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
14 years 1 month ago #95296
by Yiota
Replied by Yiota on topic Automatically add a picture when ignoring the "Choose a image" in the add an item form
To the category_item.php (override K2 template first, if not already), locate the catItemImageBlock.
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?> <!-- Item Image --> <div class="catItemImageBlock"> <span class="catItemImage"> <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo $this->item->image_caption; else echo $this->item->title; ?>"> <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo $this->item->image_caption; else echo $this->item->title; ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" /> </a> </span> <div class="clr"></div> </div><?php endif; ?>
You can make a change to that statement and load the default image you want when there is no Image present. It shouls look like this:
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?> <!-- Item Image --> <div class="catItemImageBlock"> <span class="catItemImage"> <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo $this->item->image_caption; else echo $this->item->title; ?>"> <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo $this->item->image_caption; else echo $this->item->title; ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" /> </a> </span> <div class="clr"></div> </div>
<?php else : ?>
<div class="catItemImageBlock"> <span class="catItemImage"> <a href="<?php echo $this->item->link; ?>" title="<?php echo $this->item->title; ?>"> <img src="YOUR_IMAGE_SOURCE" alt="" /> </a> </span> <div class="clr"></div> </div>
<?php endif; ?>
Put your default image to the template images or wherever you want and put the path to the src of the img.
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?> <!-- Item Image --> <div class="catItemImageBlock"> <span class="catItemImage"> <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo $this->item->image_caption; else echo $this->item->title; ?>"> <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo $this->item->image_caption; else echo $this->item->title; ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" /> </a> </span> <div class="clr"></div> </div><?php endif; ?>
You can make a change to that statement and load the default image you want when there is no Image present. It shouls look like this:
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?> <!-- Item Image --> <div class="catItemImageBlock"> <span class="catItemImage"> <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo $this->item->image_caption; else echo $this->item->title; ?>"> <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo $this->item->image_caption; else echo $this->item->title; ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" /> </a> </span> <div class="clr"></div> </div>
<?php else : ?>
<div class="catItemImageBlock"> <span class="catItemImage"> <a href="<?php echo $this->item->link; ?>" title="<?php echo $this->item->title; ?>"> <img src="YOUR_IMAGE_SOURCE" alt="" /> </a> </span> <div class="clr"></div> </div>
<?php endif; ?>
Put your default image to the template images or wherever you want and put the path to the src of the img.
Please Log in or Create an account to join the conversation.
- Ante Oja
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 14
14 years 1 month ago #95297
by Ante Oja
Replied by Ante Oja on topic Automatically add a picture when ignoring the "Choose a image" in the add an item form
Thank you so much!
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- Automatically add a picture when ignoring the "Choose a image" in the add an item form