2

I have a scenario where the client has asked us to store one of the CSS files in the media library so they can make changes to colors without coming back to the developers. I've gotten this working with the media library and using the guid in the CSS call on the page (in case someone moves the item accidentally).

What I'd like to also do is make it so when the item is saved, it automatically creates a new version, so there's a rollback version in case someone makes a mistake. I've been reading that there's some way to make this happen by default in Sitecore if you're not an admin and you have a workflow on the item, but I tried that and didn't see the version increment.

If there's no out-of-the-box way of doing it, I'm guessing using the item:saved pipeline would be the way to go, but I'm open to other suggestions if folks have run into a similar scenario.

  • Have you tried to set the workflow at template level for both versioned and unversioned media? Also, make sure that the template File has standard values and also set the workflow on it – Hishaam Namooya Aug 6 '18 at 13:53
3

From what I recall, you need a few things in place:

  1. Non-admin users (admins will bypass workflow)
  2. Two-step workflow (draft & final) that automatically approves on the save. This is the OOTB 'new version on save' approach.
  3. Versioned media. You can't version with unversioned media.

However, a warning on auto-versioning. If you get a lot of edits this is going to create a lot of versions with every single hit of the 'save' button. This can lead to some performance issues so you'll want to plan for some form of automation for cleaning up versions on the item.

6

Media items are created as Unversioned by default. Make sure that you have created a media item that uses the Versioned media template, e.g. /sitecore/templates/System/Media/Versioned/File.

When you upload the file, select the "Upload Files (Advanced)" option:

Upload image

And then select the "Make uploaded media items versionable" option:

Upload properties

There is also config setting to always created media items as versioned, but this might be excessive.

<setting name="Media.UploadAsVersionableByDefault" value="false" />

You need to set the workflow on the versioned media template, setting it on /sitecore/templates/System/Media/Versioned/File/__Standard Values will ensure the other versioned media templates inherit the workflow settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.