Orchard 1.7 Media Library create thumbnails for videos - thumbnails

When uploading a video (e.g. YouTube) in Orchard 1.7 with the new Media Library, the library creates thumbnails for your videos.
I want to create a similar library with thumbnails of my videos where the thumbnails would be links to the video detail page. I can't figure out how to create the thumbnails for the videos, only images.
The alternate view page "Content-Videos.Summary.cshtml" I'm creating looks like this:
#{
var mediaPart = ((Orchard.MediaLibrary.Fields.MediaLibraryPickerField)Model.ContentItem.Videos.Video).MediaParts.FirstOrDefault();
}
<a href="#Url.Content("~/" + Model.ContentItem.AutoroutePart.Path)">
<img src="#Display.ResizeMediaUrl(Width: 200, Height: 200, Mode: "crop", Alignment: "middlecenter", Path: mediaPart.MediaUrl)" >
</a>
I've been looking at the "Media-OEmbed.Thumbnail.cshtml" file in Ochard.MediaLibrary/Views but I'm still stuck.
The file looks like this:
#{
ContentItem contentItem = Model.ContentItem;
var media = contentItem.As<MediaPart>();
var oembed = contentItem.As<OEmbedPart>();
}
#if (!String.IsNullOrEmpty(oembed["thumbnail_url"])) {
<div class="media-thumbnail media-thumbnail-#contentItem.ContentType.HtmlClassify() mime-type-#media.MimeType.HtmlClassify()">
<img src="#Display.ResizeMediaUrl(Width: 200, Height: 200, Mode: "crop", Alignment: "middlecenter", Path: oembed["thumbnail_url"])">
</div>
}

Related

Embedding Tableau dashboard on GitHub Pages

Does anyone know of a good tutorial for embedding interactive Tableau dashboards on GitHub Pages?
You can have a look at this webpage
https://tableau.github.io/embedding-playbook/
you can basically embed using Javascript API
HTML
<script src="https://www.example.com/javascripts/api/tableau-2.js"></script>
<div id="tableauViz"></div>
JAVASCRIPT
function initializeViz() {
var placeholderDiv = document.getElementById("tableauViz");
var url = "http://public.tableau.com/views/WorldIndicators/GDPpercapita";
var options = {
width: '600px',
height: '600px',
hideTabs: true,
hideToolbar: true,
};
viz = new tableau.Viz(placeholderDiv, url, options);
}

DRY Layouts For Grails Emails?

I'm trying to clean up some of the the email views in my grails project. My team uses the same introduction, logo, and sign off for every email. I tried to place these into the traditional grails layout file and call it with the meta tag <meta name="layout" content="email"/>, but it doesn't appear to work. Is there another way I can create one singular layout for these email templates?
I was trying to figure out what you mean by DRY, I think it must be some ruby term and I guess you mean templates.
The problem with HTML emails is actually a standard problem acrosss all languages as in when it comes to including logos (headers/footers). The standards vary and whilst it may work on some mail clients may not work on for example web mail i.e. gmail and so forth.
The trick is to use inline images I will give you some sample stuff to work from:
So here is a sample Controller - this is off my own code but from different parts. It is to give you an idea or should I say not very well explained specifically around multi inline images:
class Mycontroller() {
pivate final static String TEMPLATE='/emails/emailTemplate'
def emailService
def doEmail() {
def images=[]
//Where this list contains a map of photo Ids(could be macde up, the photo content type and actual photo file Names (to go and grab from uploaded folder)
images <<[id: "uImage${photo.id}", contentType: "${photo.contentType}", file: photo.file]
images <<[id: "uImage${photo1.id}", contentType: "${photo1.contentType}", file: photo1.file]
emailService.sendEmail(user.email, subject, TEMPLATE, [instance: bean, domainName:domainName, fqdn:fqdn ], images)
}
}
I have a list if images above it containts the photo id the content type and the actual file name (in text) that is sent through to emailService.sendEmail
private void sendEmail(email,mysubject,template,templateModel,List images) throws Exception {
List<String> recipients = []
try {
mailService.sendMail {
//this must be set true and at the top for inline images to work
multipart true
if (recipients) {
to recipients
}
else {
to email
}
if (config.admin.emailFrom) {
if (Environment.current == Environment.DEVELOPMENT && config.admin.emailFromDev ) {
from "${config.admin.emailFromDev}"
} else {
from "${config.admin.emailFrom}"
}
}
subject mysubject
//actual content must be html sent to fill in a grails template
html Holders.grailsApplication.mainContext.groovyPageRenderer.render(template: template, model: templateModel)
//Main Site logo
inline 'inlineImage', 'image/png', new File("/opt/site-stuff/myLogo.png")
//Additional images
if (images) {
images?.each { a ->
inline "${a.id}", "${a.contentType}", new File("${a.file}")
}
}
}
}
catch (e) {
//throw new Exception(e.message)
log.error "Problem sending email ${e.message}"
}
}
Now the bit that you thought would just work as in using grails templates in the way you are as in layouts is not what you want instead, as above you can see it is rendering a template but the template is a typical gsp template which instead is a full on html page:
/emails/emailTemplate
<%# page contentType="text/html;charset=UTF-8" %>
<!doctype html>
<html>
<head>
<style>
.site-icon img {
width: 300px;
margin-top:-50px;
}
.site-logo img {
min-width: 25em;
max-width: 45em;
}
.menu {
background: #CCC;
}
a {
text-decoration: none;
}
.menu a {
color : #FF0000;
text-decoration: none;
font-weight:bold;
}
.menu a:hover {
color : #00FFFF;
background: #ccc;
}
</style>
</head>
<body style=" background-color: blue; font-size: 1.0em;">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr style="background: red;"><td colspan="3" class="site-logo">
<img src="cid:inlineImage"/>
<h1 style="display:inline; margin-top:-2em;"><g:message code="domain.label"/></h1>
</td>
</tr>
<g:each in="${instance.results}" var="user" status="ii">
<tr><td>
<div class="image">
<g:if test="${user.profilePhoto}">
<img src="cid:uImage${user.id}"/>
</g:if>
</div>
</td></tr>
</g:each>
</table>
You see the main problem with html emails is that CSS styles don't work very well, it works in some cases but in a lot of cases you are better off sticking to traditional tables and using style tags to properly declare your layout.
Forget about using your actual site CSS files since so far as this process goes, this is a direct email being generated and sent. It has no awareness of your site CSS files.
In regards to multiple images we are talking about
here is a list of users
usera {usera Photo} / userA Description
userb {userb Photo} / userB Description
The above solution will have all you need to add all the inline images you need to do this. This means you are attaching the images within the email so if the images are huge then you are also attaching them so the trick is to reformat the images / resize them.
For your own site logos you can do that directly and have a separate file/folder that contains actual size to be emailed but for on the fly re-sizing you could try something like this:
static Map getPhoto(Photos photo, int width=100,int height=100) {
File f
def contentType
if (photo.status==Photos.ACTIVE) {
def id = photo.id
def imageSHa = photo.imageSHa
contentType = photo.contentType
def fileExtension = photo.fileExtension
//remove . from fileExtension
def noDotExtension = fileExtension.substring(1)
def user = photo.user
f = new File(ROOT_PATH + '/' + user.username + '/' + imageSHa);
if (f.exists() && !f.isDirectory()) {
f = new File(ROOT_PATH + '/' + user.username + '/' + imageSHa+'_email');
if (!f.exists()) {
def imageStream = new FileInputStream(ROOT_PATH + '/' + user.username + '/' + imageSHa)
def image = FileCopyUtils.copyToByteArray(imageStream).encodeBase64().toString()
def caption = photo.caption
def position = photo.position
// String caption=photo.caption
//Lets present the image as a thumbNail
imageStream = new FileInputStream(ROOT_PATH + '/' + user.username + '/' + imageSHa)
def imageBuffer = ImageIO.read(imageStream)
def scaledImg = Scalr.resize(imageBuffer, Scalr.Method.QUALITY, width, height, Scalr.OP_ANTIALIAS)
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(scaledImg, noDotExtension, os)
InputStream is = new ByteArrayInputStream(os.toByteArray())
def scaledImage = FileCopyUtils.copyToByteArray(is).encodeBase64().toString()
//imageSHa = DigestUtils.shaHex(scaledImg)
byte[] data = Base64.decodeBase64(scaledImage)
OutputStream stream = new FileOutputStream(ROOT_PATH + '/' + user.username + '/' + imageSHa+'_email')
stream.write(data)
f = new File(ROOT_PATH + '/' + user.username + '/' + imageSHa+'_email');
}
return [file:f, contentType:'img/'+fileExtension.substring(1)]
}
}
return [:]
}
This now maps up to when I was doing the images mapping above:
def res = PhotosBean.getPhoto(ui.attributes.profilePhoto)
if (res) {
images << [id: "uImage${ui.id}", contentType: "${res.contentType}", file: res.file]
}
Hope this clears up a lot of headache I had to go through to achieve html emails with as many images as required and all resized to what I want

How to play youtube video within the application in iPhone

I am building an ionic/cordova application where I want to play video from Youtube live video. I am using YouTube API.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").css({"background-color": "yellow", "font-size": "200%"});
});
});
</script>
</head>
<body>
<div id="player"></div>
<script src="youtube.js"></script>
<script>
// create youtube player
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '200',
width: '200',
videoId: '0Bmhjf0rKe8',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// autoplay video
function onPlayerReady(event) {
event.target.playVideo();
}
// when video ends
function onPlayerStateChange(event) {
if(event.data === 0) {
$('html, body').animate({
scrollTop: $("#elementtoScrollToID").offset().top
}, 2000);
}
}
</script>
<div id='elementtoScrollToID' class='my_div'>Lorem Ipsum is simply dummy text of the printing and typesetting industry</div>
</body>
</html>
Using this code i have created an iPhone application using cordova.
Now when I click on youtube video its playing the video with the default player i.e. quicktime player. Its not running the video within the UIWebview frame itself(Inside my Div). But I want to show the video in the 1st half of the screen i.e my UIWebview frame. Is that possible?
In my App is shows like,
when clicking on red play button I can see the video in full screen in quicktime player like this:
But I want to show the video within the same webView frame not via quick time player. It should play like this:
Is there any other way to achieve the same? Any help will be appreciated. Thanks in advance.
In Android its working perfectly.. :-)

Add Pinterest Button to Fancybox title

I found this script online that add a pin it button to fancybox v2. Here is the working example:
http://scottgale.com/blogsamples/fancybox-pinterest/index.html
Im working on a site on the Hubspot CMS. For those who are familiar, Fancybox 1.3.4 comes included with Hubspot. And you really don't get editing access to any of the files or scripts associated with it.
The Fancybox works as a gallery module (or widget) so users can just upload images.
I was wondering if there is a way to modify this original script to work with how fancybox 1 is implemented on my site.
Here is my page:
http://www.signdealz.com/gallery-test/
Here is the script:
<script type="text/javascript">
//NOTE: this uses fancybox 2
$(document).ready(function() {
$('.fancybox').fancybox({
//set the next and previous effects so that they make sense
//the elastic method is confusing to the user
nextEffect: 'fade',
prevEffect: 'fade',
//set the position of the title
helpers : {
title: {
// title position options:
// 'float', 'inside', 'outside' or 'over'
type: 'inside'
}
},
beforeShow: function () {
//if you already have titles
//on your fancybox you can append
if(this.title) {
//set description to current title
//this will set what posts
var description = this.title;
//add pinterest button for title
this.title = '<a href="http://pinterest.com/pin/create/button/?url='+
encodeURIComponent(document.location.href)+
'&media='+
//put the path to the image you want to share here
encodeURIComponent('http://scottgale.com/blogsamples/fancybox-pinterest/'+this.href)+
'&description='+description+'" class="pin-it-button" count-layout="horizontal">'+
'<img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" align="absmiddle"/></a>'
//add title information
+'<span>'+this.title+'</span>';
//if you don't already have titles
//you can just make the title the pinterest button
} else {
//add pinterest button for title
this.title = '<a href="http://pinterest.com/pin/create/button/?url='+
encodeURIComponent(document.location.href)+
'&media=http%3A%2F%2Fwww.homesburlingtonvermont.com'+
encodeURIComponent(this.href)+
'&description=Pin from ScottGale.com" class="pin-it-button" count-layout="horizontal">'+
'<img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>';
}
}
});
});
</script>
Any help is greatly appreciated!
This is an example of how to add the Pinterest button to your fancybox's (v1.3.4) title using the options titlePosition and titleFormat. If your anchor has a title then it will be displayed along the button, otherwise the button will be displayed alone.
This script is based on the script your found for v2.x but tweaking to options for v1.3.4.
$(".fancybox").fancybox({
"titlePosition": "inside",
"titleFormat": function () {
return this.title ?
'<div class="myPint" style="height: 26px"><a href="http://pinterest.com/pin/create/button/?url='+
encodeURIComponent(document.location.href)+
'&media='+
encodeURIComponent('http://scottgale.com/blogsamples/fancybox-pinterest/'+this.href)+
'&description='+this.title+'" class="pin-it-button" count-layout="horizontal">'+
'<img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" align="absmiddle"/></a>'+
'<span>'+this.title+'</span></div>'
:
'<div class="myPint" style="height: 26px"><a href="http://pinterest.com/pin/create/button/?url='+
encodeURIComponent(document.location.href)+
'&media=http%3A%2F%2Fwww.homesburlingtonvermont.com'+
encodeURIComponent(this.href)+
'&description=Pin from ScottGale.com" class="pin-it-button" count-layout="horizontal">'+
'<img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>'+
'<span> </span></div>'
}
});
See JSFIDDLE
NOTE : this is for fancybox v1.3.4
EDIT (Jan 30, 2014) :
New JSFIDDLE using CDN for fancybox files to avoid possible 403 forbidden errors while serving the files from fancybox.net server.

Can't control width and height of video in fancy box

I eventually want to create a photo gallery... clicking on a picture will launch a You Tube video. I am using fancybox 2.0.
I have the video opening up inline but I cannot control its dimensions. Could you please take a look at this page for me and see where I am fouling up.
http://www.bytebrothers.com/bb_tester/Video_lightbox_test.htm
Thank you,
darrell#bytebrothers.com
This is how your script looks like right now
$(document).ready(function() {
$('.fancyYouTube').fancybox({
width : 400,
height : 300,
autoSize : false,
type : 'swf'
})
and this is how it should look like
$(document).ready(function() {
$('.fancyYouTube').fancybox({
width : 400,
height : 300,
autoSize : false
});
});
you are missing some closing brackets.
On the other hand, if you are using fancybox-media, you don't need to specify type:'swf'
UPDATE: when targeting youtube videos in embed (youtube iframe mode) mode, add the class fancybox.iframe to your anchor so this
<a class="fancyYouTube" href="http://www.youtube.com/embed/dx6TZgUSquY">
should be this
<a class="fancyYouTube fancybox.iframe" href="http://www.youtube.com/embed/dx6TZgUSquY">