How to use the cloudinary.url function in cloudinary

To help you get started, we’ve selected a few cloudinary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keystonejs / keystone / packages / file-adapters / lib / cloudinary.js View on Github external
publicUrlTransformed({ _meta } = {}, options = {}) {
    if (!_meta) {
      return null;
    }

    const { prettyName, ...transformation } = options;
    // No formatting options provided, return the publicUrl field
    if (!Object.keys(transformation).length) {
      return this.publicUrl({ _meta });
    }
    const { public_id, format } = _meta;

    // Docs: https://github.com/cloudinary/cloudinary_npm/blob/439586eac73cee7f2803cf19f885e98f237183b3/src/utils.coffee#L472 (LOL)
    return cloudinary.url(public_id, {
      type: 'upload',
      format,
      secure: true,
      url_suffix: prettyName,
      transformation,
      cloud_name: this.cloudName,
    });
  }
};
github keystonejs / generator-keystone / app / templates / templates / default-hbs / views / helpers / index.js View on Github external
// then `this` refers to our default scope block and kwargs
		// are stored in context.hash
		if (!options && context.hasOwnProperty('hash')) {
			// strategy is to place context kwargs into options
			options = context;
			// bind our default inherited scope into context
			context = this;
		}

		// safe guard to ensure context is never null
		context = context === null ? undefined : context;

		if ((context) && (context.public_id)) {
			options.hash.secure = keystone.get('cloudinary secure') || false;
			var imageName = context.public_id.concat('.', context.format);
			return cloudinary.url(imageName, options.hash);
		}
		else {
			return null;
		}
	};
github keystonejs / keystone-classic / fields / types / cloudinaryimages / CloudinaryImagesType.js View on Github external
var src = function (img, options) {
		if (keystone.get('cloudinary secure')) {
			options = options || {};
			options.secure = true;
		}
		options.format = options.format || img.format;
		return img.public_id ? cloudinary.url(img.public_id, options) : '';
	};
github mapmeld / 1batch / commonResponses.js View on Github external
responsiveImg: function (img, isBig) {
    var baseSize = 300;
    if (isBig) {
      baseSize *= 2;
    }
    var out = {
      _id: img._id,
      src: {
        mini: cloudinary.url(img.src, { format: "jpg", width: baseSize * 2/3, height: baseSize * 2/3, crop: "fill" }),
        main: cloudinary.url(img.src, { format: "jpg", width: baseSize, height: baseSize, crop: "fill" }),
        retina: cloudinary.url(img.src, { format: "jpg", width: baseSize * 2, height: baseSize * 2, crop: "fill" })
      }
    };
    return out;
  }
};
github keystonejs / keystone-classic / fields / types / cloudinaryimage / CloudinaryImageType.js View on Github external
return '';
		}
		options = (typeof options === 'object') ? options : {};
		if (!('fetch_format' in options) && keystone.get('cloudinary webp') !== false) {
			options.fetch_format = 'auto';
		}
		if (!('progressive' in options) && keystone.get('cloudinary progressive') !== false) {
			options.progressive = true;
		}
		if (!('secure' in options) && keystone.get('cloudinary secure')) {
			options.secure = true;
		}
		options.version = item.get(paths.version);
		options.format = options.format || item.get(paths.format);

		return cloudinary.url(item.get(paths.public_id), options);
	};
github smooth-code / blog / content / adapters / storage / cloudinary.js View on Github external
cloudinary.uploader.upload(image.path, function(result) {
        resolve(cloudinary.url(result.public_id.concat(".", result.format), cloudinaryImageSetting ).replace('http://', 'https://'));
      });
    });
github mapmeld / 1batch / commonResponses.js View on Github external
responsiveImg: function (img, isBig) {
    var baseSize = 300;
    if (isBig) {
      baseSize *= 2;
    }
    var out = {
      _id: img._id,
      src: {
        mini: cloudinary.url(img.src, { format: "jpg", width: baseSize * 2/3, height: baseSize * 2/3, crop: "fill" }),
        main: cloudinary.url(img.src, { format: "jpg", width: baseSize, height: baseSize, crop: "fill" }),
        retina: cloudinary.url(img.src, { format: "jpg", width: baseSize * 2, height: baseSize * 2, crop: "fill" })
      }
    };
    return out;
  }
};