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

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

Author Message

Ivan Švogor

Thursday 23 December 2010 6:40:08 am

Hi!

As the title says... Is there a easy way to embed youtube/flickr in xml-block, so it is displayed inline with text?

If there is no easy way, what is the hard way? - I need to somehow extend what?....

ty

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

eZ debug

Timing: Jan 18 2025 03:00:07
Script start
Timing: Jan 18 2025 03:00:07
Module start 'content'
Timing: Jan 18 2025 03:00:08
Module end 'content'
Timing: Jan 18 2025 03:00:09
Script end

Main resources:

Total runtime1.1982 sec
Peak memory usage4,096.0000 KB
Database Queries215

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 588.9922180.8203
Module start 'content' 0.00611.0331 769.8125724.0469
Module end 'content' 1.03920.1589 1,493.8594340.4297
Script end 1.1981  1,834.2891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.3462210.0002
Check MTime0.00150.1223210.0001
Mysql Total
Database connection0.00090.071410.0009
Mysqli_queries1.082290.32502150.0050
Looping result0.02932.44642130.0001
Template Total1.169497.620.5847
Template load0.00220.180220.0011
Template processing1.167397.421020.5836
Template load and register function0.00020.017710.0002
states
state_id_array0.00120.097110.0012
state_identifier_array0.00230.194120.0012
Override
Cache load0.00190.1555550.0000
Sytem overhead
Fetch class attribute can translate value0.00160.130260.0003
Fetch class attribute name0.00150.1251100.0001
XML
Image XML parsing0.00160.136260.0003
class_abstraction
Instantiating content class attribute0.00000.0017110.0000
General
dbfile0.00400.3344350.0001
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
2content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 38
 Number of unique templates used: 10

Time used to render debug report: 0.0002 secs