Youtube in Portfolio?

fonteijne's picture
Fri, 03/27/2015 - 09:02
Youtube in Portfolio?


I was wondering if it's possible to embed a Youtube video in a portfolio item.
When I create a new template: node--portfolio--{nid}.tpl.php the system won't recognize this unfortunately.

Thank you in advance

fonteijne's picture
Fri, 03/27/2015 - 09:16

I created a workaround.

Note: this isn't validated (yet?) by MegaDrupal.

Here's what I did:

Go to: structure > portfolio > manage fields
Add field: youtube_link (text)
Edit node--portfolio.tpl.php:
From line 25:
// ADDED --------------------------------
            if(render($content['field_youtube_link'][0]) != '') {
                print '<div class="flexslider">';
                print '<iframe width="750" height="500" src="'.render($content['field_youtube_link'][0]).'">                print '</div>';
                } else {
// ---------------------------------------------
            if(isset($node->field_portfolio_images['und'])) :
                $images = $node->field_portfolio_images['und'];
                print '<div class="flexslider"><ul class="slides">';
                for ($i=0; $i < count($images); $i++) {
                    print '<li>';
                    print '<img src="'.file_create_url($images[$i]['uri']).'" alt="" />';
                    print '</li>';
                print '</ul></div>';
// ADDED --------------------------------
// ---------------------------------------------

Log in or register to post comments
Have More Idea?

We are here to build your website!

No Universal solution fits all special business requirements. Our experienced team is ready with ideas and state-of-the-art technical solutions to consult the best solution within your budget.