ghostboard / ghost-purge-images

CLI tool to display & purge the uploaded images, video and audio files that currently are not used in any post, page or meta data
MIT License
90 stars 4 forks source link
blog ghost maintenance upload

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 version ghost-purge-images version How to install
3, 4, 5 latest npm install -g ghost-purge-images
>= 2.16 2.1.1 npm install -g ghost-purge-images@2.1.1
<= 2.15.x 2.0.3 npm install -g ghost-purge-images@2.0.3
0.7.2 - 1.x 1.0.0 npm 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

๐Ÿ”‘ Keys

This tool use:

Get the keys following this steps:

๐Ÿ’ก Need help? Check this step-by-step guide to create them

๐Ÿš€ Execute

Login into your server via ssh:

cd /var/www/ghost

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

ghost-purge-images display screenshot

purge

Delete all the unused files.

โš ๏ธ WARNING: Take a backup before run this

ghost-purge-images purge screenshot

๐Ÿงฉ Optional Params

๐Ÿ’ก 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/

๐Ÿ’ก The default images path is content/images

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

๐Ÿ’ก The default media path is content/media

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

๐Ÿ’ก No default value, all extensions are included

You can exclude one or more file extensions. Examples:

๐ŸŽฏ 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