How do I use the preview functionality from within an NC app?

In the dev environment (NC14) I can handcraft urls in the following format:


However, on my production environment (NC12) it seems to want the following:


There are several discrepancies that make it impossible to hardcode the img tag’s src attribute.

First, the requirement that there be an index.php at the root for my dev environment. I believe this is just a configuration of the web server, and my production environment might require the same if I configured it differently/poorly. But if I ever want to release this on the app store, it needs to somehow take that into account. What pattern do I use in the template to get the correct root/base url there?

Second, NC12 really seems to insist on preview.png instead of preview. And NC14 demands that without the file extension. Is this just a difference in the API between the two versions?

Finally, NC14 wants the fileId parameter (which is convenient), but NC12 takes “file”… and this is a path mines the “files” prefix that oc_filecache.path gets, all urlencoded. Neither seem able to take the alternate parameter. Is there any convention that both support?

As an extra… I haven’t been able to figure out yet how to maintain aspect ratio… it’s not as simple as just leaving off one dimension or the other. 0 for one 500s the server.

This should work: