keystonejs/keystone-classic

CloudinaryImage underscore methods "not a function"

開放

#4,529 建立於 2017年12月6日

 (1 則留言) (0 個反應) (0 位負責人)JavaScript (2,288 個分叉)batch import
bughelp wanted

倉庫指標

星標
 (14,656 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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

貢獻者指南