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:

  entity 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)
  }
Submitted by Danny Groenewegen on 25 March 2011 at 13:58

On 21 November 2013 at 15:15 Eelco Visser tagged @elmer

On 21 November 2013 at 15:18 Eelco Visser commented:

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.


On 21 November 2013 at 16:31 Danny Groenewegen commented:

This issue has been resolved by supporting Image.download() in a page init ( http://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(); }
      }
    }
  }

On 21 November 2013 at 16:47 Danny Groenewegen commented:

additionally, resizing in the same request as the image upload also works now ( http://yellowgrass.org/issue/WebDSL/312 ) so the resize button should not be necessary in the app


On 21 November 2013 at 16:47 Danny Groenewegen closed this issue.

Log in to post comments