Gabbar
Gabbar

Reputation: 4056

Sitecore auto-publish for media and folders

We have a structure for the media items and web page items that works something like – section -> year -> month -> day -> article/media. Currently these date folders and images uploaded to the media library are either published manually by a user or by a scheduled publish task that runs every 15 minutes resulting in a brief delay for the media or article to show up.

Is there a way to auto-publish these folders/images right after they are created? I know items can be set to workflow with finalized state having an ‘Auto-Publish’ command below it that fires right after the item reaches that final state.

I do not want to set workflow on folders and images which are based on system templates.Is there a pipeline or command I can tap into to auto-publish folders/media library on save?

Any other recommendations are welcome too.

Upvotes: 1

Views: 1710

Answers (2)

Mark Ursino
Mark Ursino

Reputation: 31435

I do not recommend auto-publishing them upon creating because if you create a folder, it will publish, then another and it will do another publish. Each publish operation will clear the Sitecore caches.

Instead, I recommend you maybe create a pipeline processor for publishing or an event handler for publishing and if you're on a media item being published, traverse up its parents in the media library (folders) and initiate the publish from there till you find one that has been published (that's you're break point on the traversal). You'd need to determine the code to see if its published. This is just one approach though.

Upvotes: 4

Bryan
Bryan

Reputation: 8778

I think you will have to create a new handler for item:saved and then check the template on it. I don't believe there is a specific pipeline for media items.

Upvotes: 1

Related Questions