3.3.0 ā€¢ Published 1 year ago

ghost-purge-images v3.3.0

Weekly downloads
3
License
MIT
Repository
-
Last release
1 year ago

ghost-purge-images

Display or clean unused uploaded files: images, documents, audio, video & thumbnail files of your Ghost blog

šŸŽ Versions compatibility

Which Ghost version are you running?

Ghost versionghost-purge-images versionHow to install
3, 4, 5latestnpm install -g ghost-purge-images
>= 2.162.1.1npm install -g ghost-purge-images@2.1.1
<= 2.15.x2.0.3npm install -g ghost-purge-images@2.0.3
0.7.2 - 1.x1.0.0npm install -g ghost-purge-images@1.0.0

āœØ Update to the last version

In your blog server, login via ssh and run:

npm install -g ghost-purge-images

šŸ’” This command will install or update ghost-purge-images globally in your server, it doesn't matter in which folder you run it

šŸ¤“ Observations

  • Due Content & Admin API, some images associated to the next resouces will be removed:
    • Authors with zero published posts
    • Tags that are not associated with a post
    • Drafts (both posts/pages) will be removed too if you are not running Ghost v2.16 or newer

      šŸ’” Why? Drafts are only available in Ghost Admin API included in Ghost 2.16

  • Backup your content folder first!

šŸ”‘ Keys

This tool use:

Get the keys following this steps:

  • On your Ghost admin, click on Integrations at the left menu
  • Click on Add custom integration and set any name
  • Copy the Content API & Admin API Keys to use them

šŸ’” Need help? Check this step-by-step guide to create them

šŸš€ Execute

Login into your server via ssh:

  • Where you have installed Ghost, usually:

cd /var/www/ghost

  • Run a command, for example:

ghost-purge-images display --content-key=YOUR_CONTENT_KEY --admin-key=YOUR_ADMIN_KEY

āš”ļø Commands

display

Print the list of all uploaded images that currently are not being used in any post, page or metadata

  • Example: ghost-purge-images display --content-key=YOUR_CONTENT_KEY --admin-key=YOUR_ADMIN_KEY

ghost-purge-images display screenshot

purge

Delete all the unused files.

āš ļø WARNING: Take a backup before run this

  • Example: ghost-purge-images purge --content-key=YOUR_CONTENT_KEY --admin-key=YOUR_ADMIN_KEY

ghost-purge-images purge screenshot

šŸ§© Optional Params

  • url

šŸ’” By default, the URL in config.production.json will be used. This may be useful for Docker or custom configurations

Example: ... --url=https://yourblog.com/

  • images-path

šŸ’” The default images path is content/images

You can change it with the optional param ... --images-path=your/custom/path/here

  • media-path

šŸ’” The default media path is content/media

You can change it with the optional param ... --media-path=your/custom/path/here

  • exclude-ext

šŸ’” No default value, all extensions are included

You can exclude one or more file extensions. Examples:

  • Excluding .webp files, adding the optional param ... --exclude-ext=webp
  • Excluding .jpg and .gif files (add a comma), adding the optional param ... --exclude-ext=jpg,gif

šŸŽÆ Troubleshooting

Error: EACCES: permission denied, unlink ANY_FILE_PATH

Permissions issue on your server, try to run in your Ghost folder:

sudo chmod -R a+rw content

šŸ“‹ Changelog

See CHANGELOG.md

šŸ‘‹ Credits

David Burgos from Ghostboard.io

šŸ‘ Contributors

āœ’ļø License

See LICENSE file

3.3.0

1 year ago

3.2.4

1 year ago

3.2.3

1 year ago

3.2.2

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.1.4

2 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.5

3 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.2.8

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago