Find file
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (29 sloc) 1.7 KB
= Page Attachments X-Sendfile
Created by Jason Garber, October 2008. Updated June 2009.
This extension works with the page_attachments extension to make attached
files available under the page they're attached to so you can link to files at
friendly URLs. Since it uses the X-Sendfile header, delivery of the attached
items doesn't block the Rails process, though it does require a couple
database queries to find the page and the attachment.
Ordinarily the page_attachments extension locates pages at URLs like
/page_attachments/0000/0001/my_image.jpg and the attachment is served directly
by the webserver. This is great for images, where the user never sees the URL,
but what about PDFs and other files where the URL is important? With this
extension installed, if you attach report.pdf to the page at
/president/board/, then the attachment is available at
The attachment:link tag uses this friendly URL format by default unless you
specify format="fast". The attachment:url tag uses the direct attachment URL
(/page_attachments/...) by default unless you specify format="friendly". The
attachment image tags always use the direct URL and you can't specify
otherwise. Loading a page full of images attached at friendly URLs is a great
way to bog down your server while Radiant does a find_by_url on each of them,
so it's not even an option.
== Installation
=== Automated install:
./script/extension install page_attachments_xsendfile
=== Manual install:
1) Unpack/checkout/export the extension into vendor/extensions of your
git clone git:// vendor/extensions/page_attachments_xsendfile
2) Restart your server