Media Management In Ghost

Hello ghost community!

I am new to ghost and loving it quite a bit. Great UI, great code, great tools, great docs. I’m all in! Please read the following with the notion that I fully intend on spearheading the efforts behind what I am proposing here.

The only thing that I do not love is how fragrantly this app disregards storage. I completely understand the sentiment behind ghost’s decision to not implement a media manger. Y’all ALMOST changed my OCD mind that this is fine. It’s not.

There are TONS of issues, questions, bug reports all revolving around this issue. Again, I am new, so please forgive me if any of this already exists in the form of plugins, or third party options. I know there are tons of integrations out there and it seems plausible that my complaints could be addressed partially or completely in those ways.

For me; I host sites for people. My hosting plans have a cap on storage with a pay-as-you-go structure for my clients. This is a structure that I am not interested in changing. Storage is cheap, but it is not free. My clients will not enjoy being billed for media that they aren’t even aware is there.

For anyone self hosting; Migrating now requires you to transfer every piece of media you ever uploaded.

Simple example of how images can add up

  1. create draft
  2. Upload test image
  3. immediately delete draft.

This image is now forever hosted on my servers with no recourse for a stock ghost install for deleting it save for manually scouring the filesystem. Yikes.

Proposed immediate breaking change:

At a minimum Ghost should aggressively delete media that is not being used when i click delete

Considering the ghost teams (understandable) lack of interest in a full blown media management UI/UX, ghost should automatically delete images that are not referenced by the site. Problem is, some people directly copy image links to re-use media and this would certainly break existing sites. Personally, I would advocate that people using workarounds should take a back seat to the maintainability of every self hosted site ever. The idea that media management is beyond the scope of this project I can accept. The idea that a stock user has no recourse for sanely/safely deleting media is something i cannot accept.

Personal workaround:
For now I will be to installing ghost-purge-images, which looks promising – I will update this post with my findings down that lane.

Long Term Goals

I need feature parity with wordpress’s media management UI. Whether thats through zapier integrations, cloudinary, or my own plugin. The purge images plugin will allow me to migrate most of my clients, it’s a hard requirement for me to migrate all of my clients to this application.

Thanks, love the project!

1 Like

Hey, Derek! Welcome to Ghost!

I’m a user and free-lancer. I self-host my own stuff, but most of my clients are on Ghost Pro. This response thus represents my own opinion, not that of the Ghost dev team.

This is beyond ‘breaking change’ in the sense I often see it used. A breaking change is a difference in functionality that means old interactions/interfaces may not work the same way they used to. This change would would produce data loss for some subset of users. I would /not/ want to see this folded into the Ghost core – there would absolutely be users who’d upgrade without realizing what would happen (or get upgraded automatically).

A media management tool would be lovely, and if it flagged unused media and gave an easy way click a button to delete those items, it would address the self-hoster storage problem. But until/unless that happens, ghost-purge-images seems like the solution for self-hosters. Unexpected automatic deletion of files is not.

I’d have no objection to a button in the admin panel that deleted unused assets with a big red warning ‘are you sure?’ message. But it doesn’t sound like that’s a priority for the Ghost dev team, and no one else has stepped up to build it into Ghost. Would that be much better than the ghost-purge-images script?

I’d like to see a media manager, too, but I don’t have the bandwidth to build one.

RE: automatically deleting (i can’t figure out how to quote like you lol)
I think you misunderstand the subtly of my suggestion and it’s likely i do not understand how users are manually re-using images. could you provide an example of how re-use images?

What I mean by “referenced in the site” is clicking delete on an image would only purge if and only if a link to the source does not exist in an existing page or post. Whether this is possible or not I have no idea.

If it were possible to only delete images that were not re-used would that be acceptable? It seems like it would be fairly trivial to implement considering there is already a tool that ID’s these unused images.

Sure. You might, for example, embed an HTML card in a post that includes a reference to an image on the site. Ghost isn’t going to know about that image (since it wasn’t added as a normal image), but deleting it would mess up that use.

I’m not opposed to a button that permanently deletes images with a warning, or this being an optional setting that defaults to off. I’m opposed to the behavior changing in a way that automatically deletes images that don’t look like they’re being used. But I’m not the Ghost Dev team, so what I think is OK doesn’t matter very much. :slight_smile:

1 Like

Do you know if ghost-purge-images accounts for embedding images in cards like this?

No idea - you’d need to read the source code. :)

OK!

Installed the purge images plugin which works out of the box for people with access to the server. Pretty useful as a nuclear option when a sites images get out of control – not for much more than that. It does seem to handle the use case of manually linking images. However, it does seem to purge the original upload (or at least thats what i think these images with the _o tag added. The plugin is scouring pages and checking the image directories against html source.


A sane path to upgrading w/o risk of data loss:
What if ghost had a “automatically clean up unused images” setting that was turned off by default?

This would prevent unexpected data loss as well as expose a clear path to upgrade for those who do want this feature.


Next Steps

  1. Closely examine all stale/closed issues in github. There are PRs that need tests/migrations that may be useful, like this one.

  2. Wire up ghost-purge-images to a button in the admin UI. This will require me diving into quite a bit of the ghost source code that I have never even looked at. I suspect this will be fairly straight forward but I have zero clue what i’m walking into.

  3. ???

  4. A fully funcitonal media library in Ghost!


  • If anyone has some tips, gotchas or qwirks in how ghost processes and stores media it would be useful it may be nice to have some insight provided.
  • Interested in helping me? my efforts will be slow going and would welcome any help.
1 Like