A Cloudinary image storage module for Ghost blogs.
Clone or download
Pull request Compare This branch is 35 commits ahead, 15 commits behind sethbrasile:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.codeclimate.yml
.editorconfig
.eslintignore
.eslintrc.yml
.gitignore
.jshintrc
.travis.yml
README.md
configuration.sample.json
index.js
package-lock.json
package.json

README.md

Build Status Code Climate Test Coverage Issue Count

IMPORTANT: You MUST be running Ghost 1.0.0 or later.

PLEASE create an issue if you have any problems.

Cloudinary has some "advanced configuration options" for Pro users and etc.. that this module does not currently handle. If you would like support for these options added, please create an issue or submit a PR!

To Use

Greenkeeper badge

NPM Installation Method

In Ghost's root directory

  1. Run npm install ghost-cloudinary-store (note the lack of --save)

  2. Install into the Ghost sources folder

2.1. Make the storage folder if it doesn't already exist mkdir versions/$GHOST_VERSION/core/server/adapters/storage/

2.2. Copy ghost-cloudinary-store from node_modules to versions/$GHOST_VERSION/core/server/adapters/storage

cp -r node_modules/ghost-cloudinary-store versions/$GHOST_VERSION/core/server/adapters/storage
  1. Install into the Ghost content folder

3.1. Make the storage folder if it doesn't already exist mkdir /$CONTENT_FOLDER/content/adapters/storage/

3.2. Copy ghost-cloudinary-store from node_modules to $CONTENT_FOLDER/content/adapters/storage/

cp -r node_modules/ghost-cloudinary-store $CONTENT_FOLDER/content/adapters/storage/
  1. Follow the instructions below for editing config.js

Git Installation Method

Note: The master branch reflects what is published on NPM

  1. Navigate to Ghost's base folder and create a directory called versions/$GHOST_VERSION/core/server/adapters/storage

  2. Navigate into this new storage directory and run git clone https://github.com/mmornati/ghost-cloudinary-store.git ghost-cloudinary-store

  3. Navigate into ghost-cloudinary-store and run npm install

  4. Follow the instructions below for editing config.js

Editing config.production.json

You have two options for configuring Ghost to work with your Cloudinary account:

  1. By using your Cloudinary credentials: cloud_name, api_key, and api_secret.
  2. By setting a CLOUDINARY_URL environment variable.

With Cloudinary credentials

In Ghost's config.production.json (the file where you set your URL, mail settings, etc..) as follows:

Note: These values can be obtained from your Cloudinary management console.

"storage": {
    "active": "ghost-cloudinary-store",
    "ghost-cloudinary-store": {
        "cloud_name": "yourCloudName",
        "api_key": "yourApiKey",
        "api_secret": "yourApiSecret"
    }
}

Further reading available here.

With a CLOUDINARY_URL environment variable

In Ghost's config.production.json (the file where you set your URL, mail settings, etc..) as follows:

"storage": {
    "active": "ghost-cloudinary-store"
}

Then set the CLOUDINARY_URL environment variable, available from your Cloudinary management console. It will look something like CLOUDINARY_URL=cloudinary://874837483274837:a676b67565c6767a6767d6767f676fe1@sample. Further reading available here. If you don't know what an environment variable is, read this.

Using Cloudinary API

You can find the documentation of what you can configure, directly on the Cloudinary website: http://cloudinary.com/documentation/image_transformations

"storage": {
    "active": "ghost-cloudinary-store",
    "ghost-cloudinary-store": {
        "cloud_name": "yourCloudName",
        "api_key": "yourApiKey",
        "api_secret": "yourApiSecret",
        "configuration": {
            "image": {
                "quality": "auto:good",
                "secure": "true"
            },
            "file": {
                "use_filename": "true",
                "unique_filename": "false",
                "phash": "true",
                "overwrite": "false",
                "invalidate": "true",
                "folder": "blog-images",
                "tags": ["blog"]
            }       
         }
    }
}

NOTE: The cloud_name, api_key and api_secret environment variables are not needed if you use the CLOUDINARY_URL environment variable.

A configuration.sample.jsonfile can be found into the project source to help you configure the plugin.

The file part into the configuration json is used to define the filename to use. By default, without any configuration, cloudinary will select a random name for the uploaded image. This can't allow you to block the same image to be uploaded plenty of times. Anytime you will upload the image it gets a new name. Configuring this part you can, for example, force Cloudinary to use the name you are providing (it is up to you to be sure about the unicity of the name).

You can find more information about and the list of possible parameters directly on the official Cloudinary documentation: http://cloudinary.com/documentation/image_upload_api_reference#upload