In this video we will configure Rules to publish our videos only after they have been converted by Zencoder. This will prevent posts from being live on our site for (potentially) hours before the video has been converted and made available on the site.

Currently all of our video posts are published when we save the post. Since I have cron set to run every three hours, this means that I could potentially have a post live on my site for three hours before the video itself actually shows up.

Now, we could tell all of our videos to convert on node save, but if you're uploading a lot of videos, or have a lot of users uploading videos, it's best to convert them in batches. This is where we run into the issue of having published posts, without videos.

The answer to this, is to have Rules publish our posts for us after the videos have been converted by Zencoder. This way if we have 20 videos that need to be converted, we can create all of the posts, but have them unpublished, have cron send the first five videos to Zencoder, and when those five are successfully converted, Rules publishes those posts. The next time cron runs, the next five are sent, and the process continues.



  • Entity API
  • Rules
  • Rules UI

Set videos to be unpublished by default

  • Go to “Structure => Content Types” (admin/structure/types)
  • Click "edit" next to video
  • Under Publishing options, uncheck "Published"
  • (Save Content Type)

Configure Rules to publish our videos

Finally, we need to setup our rule that will publish our videos once they have been successfully converted by Zencoder.

  • Go to “Configuration => Workflow => Rules” (admin/config/workflow/rules)
  • Add New Rule
    • Name: Publish video after successful conversion
    • React on event: After video conversion success
    • (Save)
  • Add condition
    • Content is of type: Video
    • (Save)
  • Add action
    • Publish content
    • (Save)

Pretty easy and it works like a charm!
I'm going to create another video and show you how it works.

  • Go to “Content => Add Content => Video” (node/add/video)
  • Title: Swing Dancing Part 2
  • Body: This is another clip of me swing dancing when I was in college.
  • Video: Browse and upload a video (select video and click upload)
  • (save)

Now we see the post, but if we go to the content page (admin/content) we’ll see that it is “unpublished”.

Now I'll run cron, and as soon as I do, it will show up on the homepage.
* Run Cron

Now, we just have to wait for Zencoder to finish encoding the video, and as soon as it does, we can refresh, and see the post with the video.