File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " netlify-plugin-cloudinary" ,
3
- "version" : " 0.0.10" ,
3
+ "version" : " 0.0.10-beta.2 " ,
4
4
"description" : " " ,
5
5
"main" : " src/index.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change 1
1
const { getQueryParams } = require ( '../../lib/util' ) ;
2
+ const { getCloudinary, getCloudinaryUrl } = require ( '../../lib/cloudinary' ) ;
2
3
3
4
exports . handler = async function ( event , context ) {
4
5
const { rawUrl } = event ;
@@ -11,10 +12,27 @@ exports.handler = async function (event, context) {
11
12
const { deliveryType } = getQueryParams ( rawUrl ) ;
12
13
13
14
const cloudName = process . env . CLOUDINARY_CLOUD_NAME || queryParams . cloudName ;
15
+ const apiKey = process . env . CLOUDINARY_API_KEY ;
16
+ const apiSecret = process . env . CLOUDINARY_API_SECRET ;
17
+
18
+ if ( ! cloudName ) {
19
+ throw new Error ( 'Cloudinary Cloud Name required. Please set cloudName input or use environment variable CLOUDINARY_CLOUD_NAME' ) ;
20
+ }
21
+
22
+ getCloudinary ( {
23
+ cloudName,
24
+ apiKey,
25
+ apiSecret
26
+ } ) ;
27
+
14
28
15
29
const remoteUrl = encodeURIComponent ( `${ endpoint } ${ imagePath } ` ) ;
16
30
17
- const cloudinaryUrl = `https://res.cloudinary.com/${ cloudName } /image/${ deliveryType } /f_auto,q_auto/${ remoteUrl } `
31
+ const cloudinaryUrl = await getCloudinaryUrl ( {
32
+ deliveryType,
33
+ path : imagePath ,
34
+ remoteHost : endpoint
35
+ } ) ;
18
36
19
37
console . log ( {
20
38
rawUrl,
You can’t perform that action at this time.
0 commit comments