keystonejs/keystone-classic

CloudinaryImage underscore methods "not a function"

Open

#4,529 创建于 2017年12月6日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)JavaScript (2,288 fork)batch import
bughelp wanted

仓库指标

Star
 (14,656 star)
PR 合并指标
 (30 天内没有已合并 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

贡献者指南