Skip to content

Commit d568ce9

Browse files
committed
renaming functions directory, deleting old file, version
1 parent abef1c9 commit d568ce9

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netlify-plugin-cloudinary",
3-
"version": "0.0.10",
3+
"version": "0.0.10-beta.2",
44
"description": "",
55
"main": "src/index.js",
66
"scripts": {

src/templates/cld_images/cld_images.js renamed to src/templates/functions/cld_images.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { getQueryParams } = require('../../lib/util');
2+
const { getCloudinary, getCloudinaryUrl } = require('../../lib/cloudinary');
23

34
exports.handler = async function (event, context) {
45
const { rawUrl } = event;
@@ -11,10 +12,27 @@ exports.handler = async function (event, context) {
1112
const { deliveryType } = getQueryParams(rawUrl);
1213

1314
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+
1428

1529
const remoteUrl = encodeURIComponent(`${endpoint}${imagePath}`);
1630

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+
});
1836

1937
console.log({
2038
rawUrl,

0 commit comments

Comments
 (0)