[MGNLREST-151] Get link to asset rendition Created: 20/Nov/17 Updated: 29/Mar/18 Resolved: 14/Mar/18 |
|
| Status: | Closed |
| Project: | Magnolia REST Framework |
| Component/s: | delivery |
| Affects Version/s: | None |
| Fix Version/s: | 2.1 |
| Type: | Improvement | Priority: | Major |
| Reporter: | Christopher Zimmermann | Assignee: | Ngoc Nguyenthanh |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | 0d | ||
| Time Spent: | 1.5d | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Release notes required: |
Yes
|
||||||||
| Date of First Response: | |||||||||
| Epic Link: | REST Phase2 | ||||||||
| Sprint: | Saigon 131, Saigon 132, Saigon 133, Saigon 134, Saigon 135, Saigon 136, Saigon 137, Saigon 138 | ||||||||
| Story Points: | 8 | ||||||||
| Description |
|
This ticket is concerned with getting links to renditions of an asset. Renditions are specified in themes. Here is an example of a link directly to a dam asset: http://localhost:8080/magnoliaAuthor
/dam/jcr:d01deefa-dba9-4708-8cfa-604320720253/image.jpg
Here is an example of a link to a rendition: http://localhost:8080/magnoliaAuthor/
.imaging/mte/travel-demo-theme/960x720
/dam/tours/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg
/jcr:content/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg
|
| Comments |
| Comment by Ngoc Nguyenthanh [ 12/Mar/18 ] |
Check link generation compares with jsonfn
[#assign myResource = cmsfn.contentByPath("/Test/main/0", "website")] ${jsonfn.from(myResource) .add("@nodeType", "image", "@link") .expand("image", "dam") .binaryLinkRendition("default","large", "portrait", "thumbnail", "mte") .print()} – jsonfn's Result
{
"@nodeType": "mgnl:component",
"image": {
"@nodeType": "mgnl:asset",
"@rendition_large": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png",
"@rendition_thumbnail": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png",
"@rendition_mte": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png",
"@link": "/dev56/dam/jcr:ca7626eb-3d40-4af8-b3f4-dd6c5490d5c1/Screen%20Shot%202018-03-06%20at%2009.29.28.png",
"@rendition_default": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png",
"@rendition_portrait": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png"
},
"@link": "/dev56/Test/main/0.html"
}
– New output "image": { "@name": "Screen-Shot-2018-03-06-at-09.29.28.png", "@path": "/Screen-Shot-2018-03-06-at-09.29.28.png", "@id": "jcr:ca7626eb-3d40-4af8-b3f4-dd6c5490d5c1", "renditions": { "default": { "mimeType": "image/png", "link": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png" }, "large": { "mimeType": "image/png", "link": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png" }, "portrait": { "mimeType": "image/png", "link": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png" }, "thumbnail": { "mimeType": "image/png", "link": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png" }, "mte": { "mimeType": "image/png", "link": "/dev56/.imaging/default/dam/Screen-Shot-2018-03-06-at-09.29.28.png/jcr:content.png" } } }
[#assign website = cmsfn.contentByPath("/", "website")] ${jsonfn.fromChildNodesOf(website).readNodeTypes("mgnl:page").add("@link").print()}
[{
"@link": "/dev56/Test.html"
}, {
"@link": "/dev56/Hello.html"
}]
Conclusion: All links are relative links which will not include protocol and host-name with port as well. |
| Comment by Ngoc Nguyenthanh [ 13/Mar/18 ] |
Usages
references:
- name: assetReference
propertyName: image
referenceResolver:
expand: true
includeDownloadLink: false
includeAssetMetadata: false
assetRenditions:
- 1600
- 1600x1200
- nonExisting
class: info.magnolia.rest.reference.dam.AssetReferenceResolverDefinition
"image": { "@name": "flickr_indonesia_michael_day_2564067897_8d17df6972_b.jpg", "@path": "/tours/flickr_indonesia_michael_day_2564067897_8d17df6972_b.jpg", "@id": "jcr:06e63c9d-ef7f-42e6-a0a1-fdecf9b7886d", "renditions": { "1600": { "mimeType": "image/jpeg", "link": "/dev56/.imaging/mte/travel-demo-theme/1600/dam/tours/flickr_indonesia_michael_day_2564067897_8d17df6972_b.jpg/jcr:content/flickr_indonesia_michael_day_2564067897_8d17df6972_b.jpg" }, "1600x1200": { "mimeType": "image/jpeg", "link": "/dev56/.imaging/mte/travel-demo-theme/1600x1200/dam/tours/flickr_indonesia_michael_day_2564067897_8d17df6972_b.jpg/jcr:content/flickr_indonesia_michael_day_2564067897_8d17df6972_b.jpg" } } } `renditions` block will be return corresponding with `imaging` definition in theme setting of a site definition. The `imaging` definition of the example mentioned above will look like:
imaging:
class: info.magnolia.templating.imaging.VariationAwareImagingSupport
variations:
"1600":
class: info.magnolia.templating.imaging.variation.SimpleResizeVariation
width: 1600
"1600x1200":
class: info.magnolia.templating.imaging.variation.SimpleResizeVariation
height: 1200
width: 1600
Non existing rendition will return a link ".../.imaging/default/..." because of it will be handled by `DefaultVariation`. |