Keyword

Automatically add a picture when ignoring the "Choose a image" in the add an item form

  • Ante Oja
  • Ante Oja's Avatar Topic Author
  • Offline
  • New Member
More
13 years 6 months ago #95295 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! :)

 

 

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

  • Yiota
  • Yiota's Avatar
  • Visitor
13 years 6 months ago #95296 by Yiota
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.

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

  • Ante Oja
  • Ante Oja's Avatar Topic Author
  • Offline
  • New Member
More
13 years 6 months ago #95297 by Ante Oja

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


Powered by Kunena Forum