A conversation with Stuart revealed that SVG is looking good. He provided some sample code:

$attributes = array(
  'type' => 'image/svg+xml',
  'data' => '/drupal6/sites/default/files/Icon.svg',
  'height' => 128,
  'width' => 128,
);

$element = array(
  '#type' => 'object',
  '#attributes' => $attributes,
);

Does this also work for a string of SVG? Where the 'data' is a string and not a file reference? It might actually be worth namespacing separate attribute keys like 'data', 'path', 'fid', 'file' (where file is a file object in preparation Drupal 7 file objects.) This type of thing would minimise the amount of internal processing of embed api.

Comments

sime’s picture

When I say "minimise the processing", I mean that a clean API shouldn't have to analyse the reference to determine what sort of reference it is.

Stuart Greenfield’s picture

This might be an ideal case to use the fact we can register a #pre_render since we are using the standard Form API. If #data was a string of SVG mark up then the #pre_render could simply save that file, modify data to point to it, and then pass the element on for rendering?

As an aside, I wrote a very quick module tonight to try out a flash based SVG viewer (http://xinf.org/trac/wiki/SvgViewer). It took about ten mnutes to write, and now the embed module can present SVG in a flash container.

sime’s picture

Yeah, pre_render sounds useful for this sort of thing. I certainly have no problems how it's done if you can make it clear about how to use the API in all scenarios.

While we're on SVG, I'll throw in the http://drupal.org/project/drawing which was a SoC project I mentored a couple of ago. It also used, or tried to use, drupal_render. But I don't mean to make it sound like SVG is the *everything* of this project. It's just a good example of how the thing you want to embed may be any of "file", "path", or "string".

dave reid’s picture

Issue summary: View changes
Status: Active » Closed (fixed)