core icon indicating copy to clipboard operation
core copied to clipboard

Image fields don't work in velocity with dotAssets

Open wezell opened this issue 3 years ago • 2 comments

  1. Create a content type testing
    • Title
    • Image (Image Field)
  2. Create a content object of testing - use DnD to upload a dotAsset to the field
  3. run this against your dotCMS instance and you can see that the velocity content object is unable to use/retrieve the image field.
curl -u [email protected]:admin -XGET https://demo.dotcms.com/api/vtl/dynamic/  \
-H "Content-Type:text/plain" \
-d '
    #set($test = $dotcontent.pull("+contentType:testing",  100,"").get(0))
    fails: $test.image
    fails: $test.getRaw("image")
    works: $test.contentObject.image
'

Output:

    fails: $test.image
    fails: $test.getRaw("image")
    works: fbdf777876229e952939a9dff93c3932

Bonus crappiness - the info is messed up for the image field as well:

Screen Shot 2022-08-09 at 10 22 46 AM

wezell avatar Aug 09 '22 14:08 wezell

dupe: #22702

wezell avatar Aug 09 '22 15:08 wezell

PR: #22710

nollymar avatar Aug 10 '22 19:08 nollymar

console output image

image broken img url

alfredo-dotcms avatar Aug 17 '22 20:08 alfredo-dotcms

the console is good the img url in the UI is broken if it is Not published, but after the content is published the url is working *the Title is undefined after being published

image

@wezell is that expected?

alfredo-dotcms avatar Aug 17 '22 20:08 alfredo-dotcms

here is the fix for the displayed title https://github.com/dotCMS/core/pull/22831

fabrizzio-dotCMS avatar Aug 23 '22 02:08 fabrizzio-dotCMS

I also verified that the VTL renders the expected values that were not present before

fabrizzio-dotCMS avatar Aug 23 '22 02:08 fabrizzio-dotCMS

Even though Alfredo's question above is valid and probably an issue, that was not the point of the original card. Passing for now and we can revisit in the future.

wezell avatar Aug 23 '22 18:08 wezell

Internal QA: The problem with the title has been fixed:

Screen Shot 2022-08-24 at 6 29 32 PM

and after running the curl test I get this output that is expected:

curl -u [email protected]:2#GemAb?DsHzp8my -XGET http://localhost:8080/api/vtl/dynamic/  \
> -H "Content-Type:text/plain" \
> -d '
>     #set($test = $dotcontent.pull("+contentType:testing",  100,"").get(0))
>     fails: $test.image
>     fails: $test.getRaw("image")
>     works: $test.contentObject.image
> '

    fails: com.dotcms.rendering.velocity.viewtools.content.BinaryMap@7a64a7e5[name=isalnds-french-polynesia.jpeg,size=100.4 K,rawUri=/contentAsset/raw-data/2a4fb69a-1f79-4bef-be47-20dec8669c78/asset,resizeUri=/contentAsset/image/2a4fb69a-1f79-4bef-be47-20dec8669c78/asset/filter/Resize,thumbnailUri=/contentAsset/image/2a4fb69a-1f79-4bef-be47-20dec8669c78/asset/filter/Thumbnail,file=/Users/nollymarlonga/workspace-dotcms/tomcat9/webapps/ROOT/assets/8/d/8d429bc7-8b44-49fb-9e3b-8f1689a64480/asset/isalnds-french-polynesia.jpeg]
    fails: com.dotcms.rendering.velocity.viewtools.content.BinaryMap@7a64a7e5[name=isalnds-french-polynesia.jpeg,size=100.4 K,rawUri=/contentAsset/raw-data/2a4fb69a-1f79-4bef-be47-20dec8669c78/asset,resizeUri=/contentAsset/image/2a4fb69a-1f79-4bef-be47-20dec8669c78/asset/filter/Resize,thumbnailUri=/contentAsset/image/2a4fb69a-1f79-4bef-be47-20dec8669c78/asset/filter/Thumbnail,file=/Users/nollymarlonga/workspace-dotcms/tomcat9/webapps/ROOT/assets/8/d/8d429bc7-8b44-49fb-9e3b-8f1689a64480/asset/isalnds-french-polynesia.jpeg]
    works: 2a4fb69a-1f79-4bef-be47-20dec8669c78

nollymar avatar Aug 24 '22 23:08 nollymar

Fixed, tested on release-22.09 // Docker // FF

Following the provided steps I'm getting the same results that the @nollymar's comment

bryanboza avatar Aug 25 '22 21:08 bryanboza