stephenjbell

Replace Embeds in Content with Standardized Versions -dotCMS

Aug 10th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.05 KB | None | 0 0
  1. #foreach($num in [1..3])
  2.     #set($videoEmbed = $blogEntry.get("videoEmbed$!{num}"))
  3.     #if($UtilMethods.isSet($videoEmbed))
  4.     <p>
  5.         #if($videoEmbed.matches(".*vimeo\.com/video/([0-9]*).*")) ## If it's a Vimeo video, use standardized Vimeo embed code for all videos
  6.             #set($vimeoId = $videoEmbed.replaceAll(".*vimeo\.com/video/([0-9]*).*","$1"))
  7.             <iframe src="http://player.vimeo.com/video/$!{vimeoId}?portrait=0&amp;color=a2d5f5" width="100%" height="326" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
  8.         #elseif($videoEmbed.matches('.*youtube.com/embed/([a-zA-Z0-9]*)".*')) ## If it's a YouTube video, use standardized YouTube embed code for all videos
  9.             #set($youtubeId = $videoEmbed.replaceAll('.*youtube.com/embed/([a-zA-Z0-9]*)".*',"$1"))
  10.             <iframe width="100%" height="326" src="http://www.youtube.com/embed/$!{youtubeId}?rel=0" frameborder="0" allowfullscreen></iframe>
  11.         #else ## Fall back to just using whatever embed code they may have dumped in
  12.             $!videoEmbed
  13.         #end
  14.     </p>
  15.     #end
  16.     #set($videoEmbed = "")
  17. #end
Advertisement
Add Comment
Please, Sign In to add comment