I used the Gallery snippet when creating a Macro. In it says to use Multiple Media Picker as the Editor however this option is not listed - just the single Media Picker.
Is there a workaround? as it's the multiple selection of images I want to enable for the user.
I had exactly same problem. I did check in Umbraco core code to see how it is working in other sides. Then I found with some tweak it can be done. I release my findings as a package. Please check this and see if it helps you?
Thanks for your reply. When I click on the link I get a 'package not found' message. In the end, for the site I was building, I just reworked the setup and didn't use the macro approach. Thanks again for your reply.
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
[DataEditor("Umbraco.MultipleMediaPicker", EditorType.MacroParameter,
"Multiple Media Picker", "mediapicker", ValueType = ValueTypes.Text, Group = "media", Icon = Constants.Icons.MediaImage)]
public class MultipleMediaPickerPropertyEditor : DataEditor
{
public MultipleMediaPickerPropertyEditor(ILogger logger)
: base(logger)
{ }
protected override IConfigurationEditor CreateConfigurationEditor() => new MultipleMediaPickerConfigurationEditor();
}
public class MultipleMediaPickerConfigurationEditor : MediaPickerConfigurationEditor
{
public override object DefaultConfigurationObject => new MediaPickerConfiguration()
{
Multiple = true
};
}
}
You can change other default config values by changing more of the MediaPickerConfiguration properties in the MultipleMediaPickerConfigurationEditor class
The benefit of defining the property editor programatically (as opposed to a package.manifest) in this instance is that we're able to specify it to only be a macro parameter by only setting its type to EditorType.MacroParameter.
That means it will not show up in the list of available property editors when adding or editing a data type and only show up when adding a macro parameter.
Just a heads up, I changed the alias for the property editor to "Umbraco.MultipleMediaPicker" which is the same as it was in v7 (ref).
That way if Umbraco is updated to officially re-add it with its original alias you wont have to change your macros again (you would have to remove the hotfix code though, otherwise you'll get a YSOD complaining about two property editors having the same alias).
Macro Parameters missing Multiple Media Picker
I used the Gallery snippet when creating a Macro. In it says to use Multiple Media Picker as the Editor however this option is not listed - just the single Media Picker.
Is there a workaround? as it's the multiple selection of images I want to enable for the user.
Thanks for any help anyone can be.
Hi Dave,
I had exactly same problem. I did check in Umbraco core code to see how it is working in other sides. Then I found with some tweak it can be done. I release my findings as a package. Please check this and see if it helps you?
Thanks
Regards, Pasang
Thanks for your reply. When I click on the link I get a 'package not found' message. In the end, for the site I was building, I just reworked the setup and didn't use the macro approach. Thanks again for your reply.
Simply add the following anywhere in your project
You can change other default config values by changing more of the MediaPickerConfiguration properties in the MultipleMediaPickerConfigurationEditor class
All of the properties available can be seen here:
https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Web/PropertyEditors/MediaPickerConfiguration.cs
The benefit of defining the property editor programatically (as opposed to a
package.manifest
) in this instance is that we're able to specify it to only be a macro parameter by only setting its type toEditorType.MacroParameter
.That means it will not show up in the list of available property editors when adding or editing a data type and only show up when adding a macro parameter.
Many thanks!
Just a heads up, I changed the alias for the property editor to
"Umbraco.MultipleMediaPicker"
which is the same as it was in v7 (ref).That way if Umbraco is updated to officially re-add it with its original alias you wont have to change your macros again (you would have to remove the hotfix code though, otherwise you'll get a YSOD complaining about two property editors having the same alias).
is working on a reply...