Page Asset Management

I’ve been toiling away at another Asset Management extension – originally I started just playing round with Keith Bingham’s extension, but I’m pretty much dumped all that code now.

http://soxbox.no-ip.org/radiant/svn/extensions/part_assets

This extension requires that you’re running on the mental branch, and that you also have my admin_parts extension installed:

http://dev.radiantcms.org/svn/radiant/branches/mental/ http://soxbox.no-ip.org/radiant/svn/extensions/admin_parts

Features of this extension:

  • Images are linked to each page, rather than being global.
  • Local images can be displayed with:

    <r:image name=”monkey.jpg”/>

  • Images from another page with:

    <r:find url=”/some/page/name> <r:image name=”monkey.jpg”/> </r:find>

  • Images can be manipulated using FlexImage. Just dump a transform_name.flexi file into ‘app/views/assets’ and you can transform images:

app/views/assets/polariod.flexi

@image.resize! :size => '100x100'
@image.border! :size => 3
@image.shadow!

And in the page:

<r:image name=”monkey.jpg” transform=”polariod”/>

There’s also a default.flexi that all images are passed through – these files contain just ruby code and get passed both the @asset and the owning @page, so you could do default transformations depending on the type of page involved.

If FlexImage isn’t installed, the extension can continue to be used as a basic asset management system.

This isn’t complete. I don’t have:
  • a way to upload images for a page that hasn’t been created yet.
  • a nice way to delete images
  • much in the way of validation
  • anything in the way of tests (it’s probably going to crash early and often)
  • any caching whatsoever (your CPU will likely get choked if you try running this in production with transforms under even slight load)
  • any confidence that it wont destroy all your data or kill your first born child (use at own risk)

I’m pretty excited about how this extension is turning out – I’d love some feedback, and any offers of patches are always welcome.