- Posts: 11
COMMUNITY FORUM
[SOLVED] Show video instead of image in item
- Thaddeus James
-
Topic Author
- Away
- New Member
Less
More
8 years 3 months ago #160558
by Thaddeus James
Show video instead of image in item was created by Thaddeus James
Hi there,
I have a large blog that uses K2. Each item uses an item image as a thumbnail in the blog layout, then as an XL image at the top of the page in item view. Some of these blog items feature videos and I would like to show the video in place of the XL image in the item page.
What I believe I need is some code to add to an override (or a plugin) that would allow me to add a youtube or vimeo link in the media tab and then have the site know to use that video in place of the XL image on the item page. Another acceptable solution would be to not have an image at all and the video could be used in the blog layout as well. Just as long as it would size down appropriately and NOT autoplay in the blog.
I have searched but can not find this functionality and do not know how to write the code myself. Hoping someone has done this and will share their solution.
Thanks!
I have a large blog that uses K2. Each item uses an item image as a thumbnail in the blog layout, then as an XL image at the top of the page in item view. Some of these blog items feature videos and I would like to show the video in place of the XL image in the item page.
What I believe I need is some code to add to an override (or a plugin) that would allow me to add a youtube or vimeo link in the media tab and then have the site know to use that video in place of the XL image on the item page. Another acceptable solution would be to not have an image at all and the video could be used in the blog layout as well. Just as long as it would size down appropriately and NOT autoplay in the blog.
I have searched but can not find this functionality and do not know how to write the code myself. Hoping someone has done this and will share their solution.
Thanks!
Please Log in or Create an account to join the conversation.
- Fábio Jordan
-
- Offline
- Senior Member
Less
More
- Posts: 59
8 years 3 months ago - 8 years 3 months ago #160578
by Fábio Jordan
Replied by Fábio Jordan on topic Show video instead of image in item
Hi there.
Edit the file "/templates/your_template/html/com_k2/templates/custom_template/item.php"
You should use if and else. Change the code you are using for "item image XL Large" for this:
That should do the trick.
Best luck!
Edit the file "/templates/your_template/html/com_k2/templates/custom_template/item.php"
You should use if and else. Change the code you are using for "item image XL Large" for this:
<!-- Check if there's a video and show it -->
<?php if($params->get('itemVideo') && !empty($this->item->video)): ?>
<div class="itemVideoBlock" id="itemVideoAnchor">
<h3><?php echo JText::_('K2_MEDIA'); ?></h3>
<?php if($this->item->videoType=='embedded'): ?>
<div class="itemVideoEmbedded"> <?php echo $this->item->video; ?> </div>
<?php else: ?>
<span class="itemVideo"><?php echo $this->item->video; ?></span>
<?php endif; ?>
</div>
<!-- If there's no video check if there's image and show it in XL Large size -->
<?php else: ?>
<?php if($params->get('itemImage') && !empty($this->item->image)): ?>
<div class="itemImageBlock">
<img src="<?php echo $this->item->imageXLarge; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
</div>
<?php endif; ?>
<?php endif; ?>
That should do the trick.
Best luck!
Last edit: 8 years 3 months ago by Fábio Jordan.
Please Log in or Create an account to join the conversation.