Anyone had the same urge to save all media items at the same time? We had to do this a couple of times now after deploy, or change in doctype of the media items. (for instance after introducing the image cropper in media items)
Very annoying to have to click hundereds of save buttons....
Maybe my Bulkmanager can help http://soetemansoftware.nl/bulkmanager. I can easily add an extra option to Bulk save selected items. I already have an additional option to regenerate crops.
We had renamed a MediaType from MediaFile to File. And to update exising data replaced the markup in one of our existing views with your code. Navigated to that view. All my mediaTypes were updated and this was confirmed on screen.
We reverted back to our original template markup and tested our changes.
We were able to use this process on our hosted sites.
Thanks, Robin, I repurposed your code to use in a web form. For those still using forms, you can create a new template and assign it to a generic page. When you hit that page the script will execute.
<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<%@ Import Namespace="Umbraco.Core" %>
<%@ Import Namespace="Umbraco.Core.Services" %>
<%@ Import Namespace="Umbraco.Core.Models" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
var mediaService = ApplicationContext.Current.Services.MediaService;
//SaveMedias(mediaService.GetRootMedia().ToList()); //Save ALL media
SaveMedias(mediaService.GetChildren(9146).ToList()); //Save all children of a specific parent node
}
public void SaveMedias(List<IMedia> medias)
{
var _mediaService = ApplicationContext.Current.Services.MediaService;
if (medias == null || !medias.Any())
return;
foreach (IMedia media in medias)
{
_mediaService.Save(media);
SaveMedias(media.Children().ToList());
Response.Write(media.Name + " saved at:" + media.UpdateDate + "<br />");
}
}
</script>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server"></asp:Content>
Save all media items button
Anyone had the same urge to save all media items at the same time?
We had to do this a couple of times now after deploy, or change in doctype of the media items.
(for instance after introducing the image cropper in media items)
Very annoying to have to click hundereds of save buttons....
Anyone ideas to do this at once?
Thanks!
Robin.
Hi Robin,
I've got round the problem previously by creating a temporary template which loops through all media items, saving each one as it goes along.
Thanks, Dan.
Hi Robin,
Maybe my Bulkmanager can help http://soetemansoftware.nl/bulkmanager. I can easily add an extra option to Bulk save selected items. I already have an additional option to regenerate crops.
Maybe something you can use?
Best,
Richard
@Dan, testing it right now Txs!
@Richard, heard of it, will test the bulkmanager tonight! Txs!
@Dan, txs for the code. ended up with the following and works like a charm:
@Robin and @Dan,
We had renamed a MediaType from MediaFile to File. And to update exising data replaced the markup in one of our existing views with your code. Navigated to that view. All my mediaTypes were updated and this was confirmed on screen. We reverted back to our original template markup and tested our changes.
We were able to use this process on our hosted sites.
All went well. Many thanks.
Sadly I am still stuck in the land of webforms for a project that I am working on but need this functionality.
Do you have an equivilent snippit that would work in the page load event of a
embedded in a master page template? Any help appreciated!
Thanks, Robin, I repurposed your code to use in a web form. For those still using forms, you can create a new template and assign it to a generic page. When you hit that page the script will execute.
is working on a reply...