Your Cart is currently empty!
Product update
Coupon
add
Coupon code invalid! Please re-enter!
AJAX loader
You are here: HomeForum
Welcome, Guest

Default image for articles without image
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Default image for articles without image

Default image for articles without image 11 years, 8 months ago #4538

  • benehem
  • OFFLINE
  • Single Product
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
Is it possible to define a default image which is displayed when the article has no image?

We use the K2 slidehow II on our sport club website and the coaches can upload news via K2. But not all of them post an image for every news entry. So I want to display a default image (the club emblem) when there's no uploaded image.

best regards
benehem

Re: Default image for articles without image 11 years, 8 months ago #4551

  • loitt
  • OFFLINE
  • Platinum Boarder
  • Posts: 2222
  • Karma: 48
Hi Bernd Schaumburg,

Could you please tell me about your joomla version now?

Thanks
Ticket System | Join our Clubs to download our extensions and templates

Re: Default image for articles without image 11 years, 8 months ago #4559

  • benehem
  • OFFLINE
  • Single Product
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
It's 1.5.26

best regards
Bernd Schaumburg

Re: Default image for articles without image 11 years, 8 months ago #4564

  • loitt
  • OFFLINE
  • Platinum Boarder
  • Posts: 2222
  • Karma: 48
Hi Bernd Schaumburg,

Please open the yt_k2slideshowii.php in "your_site/modules/mod_yt_k2_slideshowii/assets", finding:

function update($items){		
		$tmp = array();
		
		foreach ($items as $key => $item) {
			if (!isset($item['sub_title'])) {
				$item['sub_title'] = $this->cutStr($item['title'], $this->max_title);
			}
			if (!isset($item['sub_main_content'])) {
				$item['sub_main_content'] = $this->cutStr($item['content'], $this->max_main_description);
			}
			if (!isset($item['sub_normal_content'])) {
				$item['sub_normal_content'] = $this->cutStr($item['content'], $this->max_normal_description);
			}
			
			
			if (!isset($item['thumb']) && $item['img'] != '') {
				$item['thumb'] = $this->processImage($item['img'], $this->thumb_width, $this->thumb_height, $item['id']);
                
			} else {
				$item['thumb'] = '';
			}
            if($this->imagesource == 1){
                $item['thumb'] = $item['img'];
            }
            if($item['thumb'] == ""){
                if($this->themes == 'theme5'){
                    $item['small_thumb'] = JURI::base()."modules/mod_yt_k2_slideshowii/assets/no_images.png";
                }
            }else{

                $item['small_thumb'] = $this->processImage($item['img'], $this->small_thumb_width, $this->small_thumb_height, $item['id']);

            }
            
			$tmp[] = $item;
            
            
		}
		
		return $tmp;				
	}


change to:

function update($items){		
		$tmp = array();
		
		foreach ($items as $key => $item) {
			if (!isset($item['sub_title'])) {
				$item['sub_title'] = $this->cutStr($item['title'], $this->max_title);
			}
			if (!isset($item['sub_main_content'])) {
				$item['sub_main_content'] = $this->cutStr($item['content'], $this->max_main_description);
			}
			if (!isset($item['sub_normal_content'])) {
				$item['sub_normal_content'] = $this->cutStr($item['content'], $this->max_normal_description);
			}
			
			
			if($item['img'] == ''){
				$item['img'] = no_image_path;			
			}
		
			if (!isset($item['thumb'])) {
				$item['thumb'] = $this->processImage($item['img'], $this->thumb_width, $this->thumb_height, $item['id']);
                
			}
            if($this->imagesource == 1){
                $item['thumb'] = $item['img'];
            }
           

            $item['small_thumb'] = $this->processImage($item['img'], $this->small_thumb_width, $this->small_thumb_height, $item['id']);
            
			$tmp[] = $item;
            
            
		}
		
		return $tmp;				
	}



In which, no_image_path is the path of your no image. Example: "modules/mod_yt_k2_slideshowii/assets/no_images.png"

Thanks
Ticket System | Join our Clubs to download our extensions and templates

Re: Default image for articles without image 11 years, 8 months ago #4586

  • benehem
  • OFFLINE
  • Single Product
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
Thank's for your solution.

But I've done it in another way. I have several slideshows on the website and each of them has to have another default image. I use theme 2 so i've changed line 88 in theme2.php to:

<?php if($link_image == 1):?><a href="<?php echo ($link_image)?$item['link']:"#";?>" target = "<?php echo $target;?>" style="display:<?php echo ($show_main_image)?"block":"none";?>;" ><?php endif;?><img src="
<?php if($item['thumb']!="") {echo $item['thumb'];} else {echo '/media/k2/items/default_'.$module->id.'.jpg'; } ?>" 
title="<?php echo $item['title'];?>" alt="<?php echo $item['title']?>" /><?php if($link_image == 1):?></a><?php endif;?>


Now I can store the default images in root/media/k2/items/default_ + module_id + .jpg

regards
benehem

Re: Default image for articles without image 11 years, 8 months ago #4587

  • loitt
  • OFFLINE
  • Platinum Boarder
  • Posts: 2222
  • Karma: 48
Hi Bernd Schaumburg,

I think that you have to add the code line in each theme which you want to display the default no image.

It is repeated many times.

Thanks
Ticket System | Join our Clubs to download our extensions and templates
The following user(s) said Thank You: benehem
  • Page:
  • 1
Time to create page: 0.22 seconds

Notification

Please find your issue via Suggested Posts before submitting your question. We have solved the most of issues and maybe your issue was solved before.

Latest My Topics

No posts to display.

Love all our templates?

Join our membership clubs starting at $49 only for access to all of our templates

Join Now
Home Pricing
Your Cart is currently empty!
Product update
Coupon
add
Coupon code invalid! Please re-enter!
AJAX loader
SearchSupport
Magento Themes Magento Extensions Free Magento Extensions Prestashop Themes Prestashop Modules Magento 2 Themes