I need to use another image for the K2 article for the another lang. For example, we have 2 languages used for the site: en (by default) and additional pl. In the administrator UI we can edit only general image preview. I made some edits to use another image for the 2nd lang. First of all, we need to create extra field with the name Additionalimagepl. Then we can open template file (e.g., /templates/template/html/com_k2/news/item.php), find this part:
<a class="modal" rel="{handler: 'image'}" href="<?php echo $this->item->imageXLarge; ?>" title="<?php echo JText::_('K2_CLICK_TO_PREVIEW_IMAGE'); ?>"> <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" /> </a>
and edit this code in the following way:
<?php if(strpos($_SERVER['REQUEST_URI'], '/pl/') !== false):?> <?php if($this->item->extraFields->Additionalimagepl->value != ''): ?> <?php $varimg = $this->item->extraFields->Additionalimagepl->value ; $varimg = preg_replace('/<img src="/',"",$varimg); $varimg = preg_replace('/" alt="" \>/'," ",$varimg); echo '<a class="modal" href="' . $varimg . "" . "" ; ?> <?php echo $this->item->extraFields->Additionalimagepl->value; ?> </a> <?php else: ?> <a class="modal" rel="{handler: 'image'}" href="<?php echo $this->item->imageXLarge; ?>" title="<?php echo JText::_('K2_CLICK_TO_PREVIEW_IMAGE'); ?>"> <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" /> </a> <?php endif; ?> <?php else: ?> <a class="modal" rel="{handler: 'image'}" href="<?php echo $this->item->imageXLarge; ?>" title="<?php echo JText::_('K2_CLICK_TO_PREVIEW_IMAGE'); ?>"> <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" /> </a> <?php endif; ?>