keystonejs/keystone-classic

CloudinaryImage underscore methods "not a function"

Open

#4529 opened on Dec 6, 2017

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (14,656 stars) (2,288 forks)batch import
bughelp wanted

Description

Expected behavior

When running an underscore function like "thumbnail" on a CloudinaryImage type with picture._.thumbnail(300,300) or perhaps even picture.thumbnail(300,300) it should output a cloudinary url with the appropriate transform. but this only works on the CloudinaryImages (Plural) type.

Actual/Current behavior

Throws errors, for example. If i set my "artist" model to have:

picture: { type: Types.CloudinaryImage, initial: true },

and in my view, attempt to use one of the underscore methods for example thumbnail:

img(src=artist.picture._.thumbnail(300,300))

I get:

Cannot read property 'thumbnail' of undefined

and when i try without the underscore:

img(src=artist.picture.thumbnail(300,300))

I get:

artist.picture.thumbnail is not a function

But if i change the type from CloudinaryImage to CloudinaryImages:

picture: { type: Types.CloudinaryImages, initial: true },

Then loop through:

if artist.picture each picture in artist.picture img(src=picture.thumbnail(300,300))

Then I get my desired result and i don't even need to use the ._. If i use the underscore I get this again.

Cannot read property 'thumbnail' of undefined

Steps to reproduce the actual/current behavior

See above

Environment

Software Version
Keystone 4.0.0-beta.5
Node 8.2.1

Contributor guide