Share » Forums » Developer » Easy way to add flickr/youtube in...

Easy way to add flickr/youtube in article (xml-block)

Easy way to add flickr/youtube in article (xml-block)

Thursday 23 December 2010 6:40:08 am - 7 replies

Author Message

Olav Frengstad

Thursday 23 December 2010 8:57:25 am

I don't have a solution that will work immediatly. But we are currently working on some oEmbed functionality for services like Youtube, Flickr, Twitter and similar.

In the meantime Youtube videos can be displayed by clicking the "Custom Tag" link (the one with the <?> sign). I don't know if that is functionality custom fitted for share.ez.no or if its available for all ez installation, can some confirm if this is included in default ez installations? 

Nicolas Pastorino

Sunday 26 December 2010 12:32:42 pm

Hi,

The custom tag idea is probably the easiest way to go, as Olav pointed out. Here is how to proceed to add your own custom tag.

1. Open your preferred content.ini.append.php, and add the following :

[CustomTagSettings]
AvailableCustomTags[]=youtube
CustomTagsDescription[youtube]=YouTube video

[youtube]
CustomAttributes[]=video_id
CustomAttributes[]=width
CustomAttributes[]=height

2. Create a template named youtube.tpl in <your_custom_extension>/design/standard/templates/content/datatype/view/ezxmltags/ , containing the following code :

{if $width|not}{set $width=425}{/if}
{if $height|not}{set $height=344}{/if}

<div class="object-center">
    <object type="application/x-shockwave-flash" width="{$width|wash}" height="{$height|wash}" data="http://www.youtube.com/v/{$video_id|wash}&amp;hl=en&amp;fs=1&amp;rel=0&amp;color1=0x666666&amp;color2=0xf15e22">
        <param name="movie" value="http://www.youtube.com/v/{$video_id|wash}&amp;hl=en&amp;fs=1&amp;rel=0&amp;color1=0x666666&amp;color2=0xf15e22" />
    </object>
</div>

3. Clear the caches (INI and template)

You should now be able to choose the "YouTube video" custom tag from the pop-up showing-up when clicking the <?> button, from the Online Editor.

Cheers !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Ivan Švogor

Tuesday 28 December 2010 6:21:05 am

Hey Nicolas, actually I just figured it out yesterday and it's similar to your solution. It's pretty straightforward ez publish logic... Anyways, thank you!

Torbjørn L.

Friday 18 February 2011 2:33:53 am

just a quick reply regarding the placement of the tpl file - you don't need to add it to the standar, it is sufficient to place it like this:

\<yourext>\design\<your_design>\templates\content\datatype\view\ezxmltags

Other than that, nice info - very helpful

Marko Žmak

Monday 21 February 2011 5:49:14 am

Just a drop about this one...

The best solution for embedding video in the text I found is this one...

  • have a special video class that supports both uploading video files and pasting youtube URL-s
  • override the embed.tpl template for this class so that it displays the player
  • publish the video as an object of the video class and insert it in the article via object embedding

This approach has some advantages over using custom tag:

  • you copy-paste the youtube URL only once and then you can easily embed it many times in many articles
  • the video can be indexed by eZ search mechanism
  • the video can be indexed by search engines
  • the video can also be displayed standalone
  • you can also add a title, a thumbnail and a description to the video
  • it opens other possibilities like for example embedding entire video galleries

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Torbjørn L.

Monday 21 February 2011 6:03:46 am

yeah, I've already made a new youtube class that does that. I haven't really added anything else then a name and url that is stripped and used, but could as you say add a image and other attributes.

good call.

Marko Žmak

Monday 21 February 2011 9:34:50 am

yeah, I've already made a new youtube class that does that. I haven't really added anything else then a name and url that is stripped and used, but could as you say add a image and other attributes.

good call.

Another neat trick is to use the youtube's thumbnail for the video's thumb on your site. You extract the id of the movie from the youtube URL and then use it to generate the URL of the youtube thumbnail.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu