keystonejs/keystone-classic

CloudinaryImage underscore methods "not a function"

Open

#4529 aperta il 6 dic 2017

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)JavaScript (2288 fork)batch import
bughelp wanted

Metriche repository

Star
 (14.656 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor