Uploading Videos Directly to Ghost: A Developer's Guide

Uploading Videos Directly to Ghost: A Developer's Guide
On this page

As a developer, I've been exploring ways to integrate video content directly into Ghost posts without relying on third-party hosting services like YouTube or Vimeo. In this post, I'll share my experience and insights on uploading videos locally to Ghost.

Supported Video Formats and Size Limits

Ghost supports video uploads in the following formats: .mp4.webm, and .ogg.

The maximum file size for video uploads depends on your Ghost(Pro) plan:

  • Free trial: 5MB
  • Starter: 5MB
  • Creator: 100MB
  • Team: 250MB
  • Business: 1GB

Self-hosted Ghost Video File size

If you use the self-hosted Ghost version, you can edit your NGINX configuration file if you need to increase the upload limit for your self-hosted Ghost instance. Navigate to your Ghost installation folder, open the NGINX config file, and modify the client_max_body_size value.

The first step is to check your NGINX configuration's default max upload size. Ghost has a default limit of 50MB, but you may need to increase this if you're working with larger files. It would help if you did this:

  1. Log into your server and navigate to your Ghost installation folder: cd /var/www/ghost.
  2. Open your NGINX config file: nano system/files/your-domain-name.conf.
  3. Locate the line client_max_body_size {VALUE}M; and update the {VALUE} to your desired limit (e.g., client_max_body_size 150M; for a 150MB limit).
  4. Save the file and restart NGINX: sudo service nginx restart.

Embed Videos in Email Newsletters

This is not the case only when sending Ghost newsletters - most email clients have security limitations that prevent embedded videos from displaying correctly.

A workaround for including a video in a newsletter is to use a hyperlinked screenshot or title screen image instead of directly embedding the video. By including a clickable image, you can still provide a link for readers to view the video while ensuring the newsletter content displays correctly across different email platforms.

Deleting Unused Video Files

Another concern I've encountered is the ability to delete unused video files from the server. Removing a video from a post doesn't automatically delete the file from the server. This can lead to accumulating unused files over time.

Ghost does not have built-in functionality to delete these unused files automatically. If you're self-hosting Ghost, you can manually delete the files via SSH.

How to delete unused video files on Ghost

  1. Log into your server and navigate to your Ghost installation folder: cd /var/www/ghost/content/media.
  2. Inside media folder you will find folders ordered by year
  3. Browse them and look for files that you want to delete
  4. Be careful because you could delete something that you are using

A handy ghost-purge-images tool can help you quickly manage and clean up unused media files. You can delete unused images, video, and audio files in any post, page, or meta data and save space on your server.

GitHub - 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
CLI tool to display & purge the uploaded images, video and audio files that currently are not used in any post, page or meta data - ghostboard/ghost-purge-images

It works with Ghost versions 3, 4, and 5, and is compatible with Ghost 2.16 and newer. With simple commands, you can quickly identify and remove unused files, freeing up space and keeping your Ghost blog organized and efficient.

Conclusion

In summary, uploading videos directly to Ghost is a nice feature that can enhance your posts, but it has some limitations and challenges. As a developer, it's important to know the supported video formats, size limits, and potential issues that may arise during the upload process.

To enhance the video player experience, Ghost could add features like maximizing the video window and optimizing the player for mobile devices.

If you encounter any further issues or have additional questions, please contact us. We can help you with Ghost Video problems.

Ghost Themes

Take a look at our Premium and Free Ghost Themes that will help you start building your new Ghost Publication.

Explore Ghost Themes