Opened 10 years ago

Last modified 7 years ago

#653 accepted enhancement

Add capability for embed codes to show media on other websites

Reported by: Nick Owned by:
Priority: minor Milestone:
Component: programming Keywords: embed, small
Cc: Parent Tickets:


I'm looking for the ability to provide my mediagoblin users the ability to copy and paste a snippet of code - a la youtube or vimeo - to display media in another website.

Without having researched it, I'd imagine what would probably be done for video is some sort of iframe? Or alternatively, a javascript snippet with parameters that add the video.js player to the existing page and then includes the video element in its place. I could look at how other video players handle this too.

For images, it's pretty trivial once the infrastructure for configuring and displaying the embed code is in place.

Change History (7)

comment:1 by Christopher Allan Webber, 10 years ago

I think this would be fairly easy to add, actually. I imagine this working the following way:

Each media type currently provides a MEDIA_MANAGER; see mediagoblin/media_types/video/ Add to that media type two new fields:

  • embed_func: if provided, this is a function which takes two arguments: (request, media), and returns a string of text to appear in a copy/paste embed code box.
  • embed_view: This contains a pseudo-view function that takes (request, media) as arguments and returns a response. More on this in a second.

For some media types such as images, embed_func might be enough. Embedding an image might really just be as simple as providing the text:

  <a href="/u/cwebber/m/unhappy-birthday/">
    <img href="/path/to/unhappy-birthday-med.jpg"
         alt="Unhappy birthday" />

But for videos and audio, yes we should probably take an <iframe/> approach... so in that case those functions need to provide an embed view. Hence there should be a new view added to the MEDIA_MANAGER that would be at a url like:


and which has a view roughly like:

def media_embed(request, media):
    embed_func = media.media_manager.get('embed_func')

    if embed_func:
        return embed_func(request, media)
        return render_404(request)

I think that should probably cover the needs of this! Does that seem fairly sensible?

comment:2 by pythonsnake, 10 years ago

Owner: set to pythonsnake
Status: newin_progress

comment:3 by Julien Gouesse, 10 years ago


Why not using the video HTML5 markup with the WebM source file where it is supported and a Java applet as a fallback using JogAmp + LibAV elsewhere?
You should look at this:

Of course, I would prefer a solution without plug-in and the support of applets in OpenJDK isn't optimal (whereas Icedtea Web Start works very well).

We could use Ogg Theora and WebM with the video HTML5 markup and just display an understandable error message when the browser can't support those formats because of a lack of codec or because it is too old to support HTML5.

comment:4 by Julien Gouesse, 9 years ago

What is the current situation of this request for enhancement? In the meantime I use the thumbnail in some HTML code as a clickable image that leads to the GNU Mediagoblin page containing the video but:

  • the thumbnail is really small
  • it's not very explicit
  • I would prefer playing the video in the same web page

embed_func could return some code to embed the videojs player.

comment:5 by Beanow, 9 years ago

Like #409, I would be interested in any status updates related to embedding standards.
Has this issue had any updates?

comment:6 by Ben Sturmfels, 7 years ago

Owner: pythonsnake removed
Priority: majorminor
Status: in_progressaccepted

I'm un-assigning this ticket, since it hasn't seen any progress, but would be a great feature to have.

comment:7 by Ben Sturmfels, 7 years ago

Keywords: small added

Marking as small-sized as Chris has scoped this fairly clearly above.

Note: See TracTickets for help on using tickets.