keystonejs/keystone-classic

CloudinaryImage underscore methods "not a function"

Ouverte

#4 529 ouverte le 6 déc. 2017

 (1 commentaire) (0 réaction) (0 personne assignée)JavaScript (2 288 forks)batch import
bughelp wanted

Métriques du dépôt

Stars
 (14 656 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

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

Guide contributeur