Drupal SVG Display Module Ideas

I've been working on rewriting my Wordpress SVG inlay plugin as a Drupal module. So far it works pretty well but I'm not ready to say it's secure or functional for most sites. The basic concept of the SVG inlay is that sometimes you just want to display an SVG image in a post or page. Not as a style element but as something that visitors want to look at which is relevant to the content. Like a chart, a graph, a network diagram, maybe even a little game. My intent is to build something that would be a filter available on a content type for trusted site users. The people who have access to this would also be people who can upload files and edit using plain HTML and Javascript. This eases the work for me since I can assume that the users don't have malicious intent. They may make mistakes but they're not out to trash the site - if they were then they can do that with just their HTML and Javascript access.

The SVG to be displayed exists in an external file on the server that Drupal can see.

I've been thinking about features that would be useful in such a module. The most important feature is that it should do everything possible to display the SVG. In some cases this would mean that substituting a PNG graphic is acceptable. In other cases maybe it could use Batik or one of the Flash-based SVG viewers that some people are working on. If none of these is suitable then the module would have no choice but to show error text that gives the visitor some idea of what they can do to make their user agent (browser) show the image.

Since I'm on the subject of compatibility, maybe it would be worthwhile to allow site authors to do some user agent sniffing or feature detection. Then if an implementation is known to not support an essential feature of the image being displayed, a fallback could be attempted. I know it's not a pleasant option but I'm trying to be purely pragmatic: I want this to make life as easy for website creators as possible.

As an advocate of SVG, I like to make demos. I need to show the source. I intend to add a tab to display the source. This should be nicer than the ad hoc way I've done it in the past. Sometimes I used prettified XML and sometimes just plain text. Demos are better when people can mess with them. So another feature that would be nice would be an edit box where the source could be edited. This is a little more challenging given that I want to work across browsers but it should still be doable.

The source and editor tabs aren't useful to everyone of course, so I can add configuration for those features. Either in the module settings or I could make it part of the svginlay tag that I use.

After all that work I have to consider how such a module should interact with other popular modules. Are there any APIs that should be exposed? Is there a way to integrate with the CCK or Views modules? Still lots to decide and lots to build but I think it'll be a useful module. Anyone with suggestions, comment here and give me ideas what people expect.

Your rating: None Average: 2.6 (19 votes)

rsvg does as decent job with rendering svg to raster formats, it can is used with some MediaWiki installations. I already thought about using it with a CCK FileField or a new SVGField module derived from it. This is only one aspect of your module idea, but maybe it helps.

I'm jandd @drupal.org if you'd like to contact me.

Thanks for the pointer, rsvg looks promising. I (still) haven't made progress on the goals I laid out here but I'm going to need to soon.