add a function to get direct link to Image
It would be convenient to have a function or template that produces a direct link to an Image stored in the database, in addition to the current output(Image) which always adds the img tag.
Workaround using rendertemplate:
Submitted by Danny Groenewegen on 25 March 2011 at 13:58entity Test{ img :: Image } var t:=Test{} define page root(){ var s := rendertemplate(test()).split("src='")[1].split("' ></img>")[0] form{ input(t.img) submit action{ } {"save"} } output(t.img) test() output(s) } define test(){ output(t.img) }
Issue Log
I have tried using this in the blog application:
https://github.com/eelcovisser/blog/blob/master/gallery/gallery-view.app
However, it does not work, which is holding back making blog into a proper CMS.
This issue has been resolved by supporting Image.download() in a page init ( https://yellowgrass.org/issue/WebDSL/453 ). Using that method you can also add a normal page access control rule to protect the image.
Example usage in the blog app:
define page photo(photo: Photo) { navigate photoFullscreen(photo, "t") { "[thumbnail]" } navigate photoFullscreen(photo, "s") { "[small]" } navigate photoFullscreen(photo, "m") { "[medium]" } navigate photoFullscreen(photo, "l") { "[large]" } navigate photoFullscreen(photo, "o") { "[original]"} <img src=navigate(photoFullscreen(photo, "t")) /> } define page photoFullscreen(photo: Photo, size: String) { init{ case(size) { "t" { photo.thumbnail.download(); } "s" { photo.small.download(); } "m" { photo.medium.download(); } "l" { photo.large.download(); } "o" { photo.original.download(); } } } }
additionally, resizing in the same request as the image upload also works now ( https://yellowgrass.org/issue/WebDSL/312 ) so the resize button should not be necessary in the app
Log in to post comments