|
HowToUseIt
Of course, first you must add it to your INSTALLED_APPS: INSTALLED_APPS = (
....
'oembed',
)Then in your template, include the oembed tags {% load oembed_tags %}Then, surround something with the oembed tag. It will search for oembed-able links and replace them with the proper embed: {% oembed %}
There is this great video at http://www.viddler.com/explore/SYSTM/videos/49/
{% endoembed %}Will result in: There is this great video at <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="222" id="viddlerplayer-e5cb3aac"><param name="movie" value="http://www.viddler.com/player/e5cb3aac/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/player/e5cb3aac/" width="320" height="222" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddlerplayer-e5cb3aac" ></embed></object> There is an optional width and height parameter, that can be invoked thusly: {% oembed 320x240 %}...{% endoembed %}
|
► Sign in to add a comment
I'm trying to embed following link http://www.youtube.com/watch?v=w2loARnxvx8 , but it doesn't replace it with object code. If i put http://www.viddler.com/explore/SYSTM/videos/49/ instead - it works. What can be a reason for such behavior? I didn't change initial configuration.
I don't think YouTube? has implemented an oembed service yet.
Works fine for me
You can see a list of supported sites here:
One thing to watch out for is that some sites aren't oembed compliant or don't have a full featured request API. YouTube?, for instance, doesn't seem to care what width or height or max-width/height I request; eg,
still returns the default width and height even though I ask for 234x179
I added a patch to my sandbox to force an override in the case of YouTube?. It can be added to any site by altering the 'force_override' field in fixtures/oembed/initial_data.json to 'true' instead of 'false'.
The patch hasn't been added to trunk. To apply the patch yourself download the diff attachment in the 5th ticket:
From the directory
type the command (or /path/to/width_height_override.diff)feedback welcome.
link.html is missing
So I have oembed in my site, but I don't know which version.
How do I know which revision or version I have? I just don't know whether to update or not.
Hi,
I did what the tutorial said about installing the oembed stuff and added the 'oembed' to the INSTALLED_APPS and added the {% load oembed_tags %} and
{% oembed %} There is this great video at http://www.viddler.com/explore/SYSTM/videos/49/ {% endoembed %}
but it only displays the content inside oembed and endoembed as a text and that's it. There is no link there is nothing else than text. There's no errors anymore, but it just doesn't seem to work at all.. Any ideas what the problem might be?
What is the preferred way to use oembed together with filters like urlize or linebreaks? By default it does not work when those filters are applied on content before oembeding it.
using a wikipedia link as http://en.wikipedia.org/wiki/James_A._Garfield results a TemplateDoesNotExist?: oembed/link.html error.
Answering my own question from half a year ago, currently we're doing something like:
{{text|sanitize:"b i em strong ol li ul blockquote a:href spoiler"|spoiler|safe|oembed|urlimagize|linebreaks}}
This has the drawback of not being able to specify the size of the embedded video. Adding a opssibility to do sth like:
{{text|sanitize:"b i em strong ol li ul blockquote a:href spoiler"|spoiler|safe|oembed:"425x344"|urlimagize|linebreaks}}
would be nice.
Using the oembed tag instead of a filter is not a solution as this:
{% oembed 425x344 %}{{text|sanitize:"b i em strong ol li ul blockquote a:href spoiler"|spoiler|safe|urlimagize|linebreaks}}{% endoembed %}
would render strange results (the link would be replaced with <a href="youtubelink">youtubelink</a> and the video would show up twice as oembed is not wise enough to understand the <a href syntax.
You can check our code at http://bitbucket.org/filmaster/filmaster-test/src/tip/film20/templates/forum/shortreview_forum.html
Thanx borys.musielak your answer helped me
Had the same problem when using markdown with oembed, but thankfully writing a filter that takes these parameters is almost completely copy and paste:
from django import template from django.template.defaultfilters import stringfilter from oembed.core import replace register = template.Library() @stringfilter def my_oembed(input, args): args = args.split() if len(args) > 1: raise template.TemplateSyntaxError("Oembed tag takes only one (option" \ "al) argument: WIDTHxHEIGHT, where WIDTH and HEIGHT are positive " \ "integers.") if len(args) == 1: width, height = args[0].lower().split('x') if not width and height: raise template.TemplateSyntaxError("Oembed's optional WIDTHxHEIGH" \ "T argument requires WIDTH and HEIGHT to be positive integers.") else: width, height = None, None kwargs = {} if width and height: kwargs['max_width'] = width kwargs['max_height'] = height return replace(input, **kwargs) register.filter('my_oembed', my_oembed)