User Tools

  • Logged in as: anonymous (anonymous)
  • Log Out

Site Tools


mantisbt:linked_attachments

Linked Attachments from YouTube, Flickr, and others

Author: Victor Boctor

Introduction

Mantis supports attaching files to issues and projects. Mantis also supports auto-preview for image attachments and there are patches to make it auto-preview flag files as well. This feature allows Mantis to support linked as attachments. This is where a user attaches a link rather than an actual file. The link should be auto-previewed if it is pointing to a recognized format. This is similar to what Wikis do with hyper links to images where they auto-embed the image on the page. The recognized formats should include:

  • YouTube videos (and possibly other video hosts like blip.tv, viddler, etc).
  • Flickr images (and possible other image hosts like smugmug, tinypic, etc).
  • Flash Files

The process of converting a link to an embedded object or tags should be done using a custom function. This allows Mantis admins to override such function to support their own formats. They can also easily contribute it to Mantis. Some of these handles will just check the extension of the file at the end of the URL and others will recognize a URL to a certain website like YouTube.

Design

  • Implement core/embed_api.php which provides a function for each link type that is supported.
  • embed_api.php also provides a function that takes a URL and generates the necessary HTML.
  • Implement a custom function that calls the function that takes a URL and generates the necessary HTML.

Storage in the Database

  • The URL attachments will be stored in the same tables as the normal files (i.e. mantis_bug_file_table and mantis_project_file_table)
  • The file type will be “URL”.
  • The file name will the link URL.
  • diskfile, folder will be empty.
  • filesize will be empty.
  • The rest of the fields will remain as is.

YouTube

http://www.youtube.com/watch?v=LBs3DsIcRYI

Will be replaced with:

<object width="425" height="350">
  <param name="movie" value="http://www.youtube.com/v/LBs3DsIcRYI"></param>
  <param name="wmode" value="transparent"></param>
  <embed src="http://www.youtube.com/v/LBs3DsIcRYI" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>
</object>

Feedback

  • Please provide ideas and feedback in this section. Also feel free to fill in details for other types of links to be supported. Each section should have the original link, the HTML to generate and ideally the PHP code that does the conversion (optional).
    • In the example above, how will mantis know the dimensions of the movie URL? In fact, how does it know it's a movie? Should mantis do a HEAD method on the URL and peek at the content type?
mantisbt/linked_attachments.txt · Last modified: 2011/11/16 07:39 by atrol

Driven by DokuWiki