Index: src/main/java/org/onehippo/addon/frontend/gallerypicker/dialog/GalleryPickerDialog.java
===================================================================
--- src/main/java/org/onehippo/addon/frontend/gallerypicker/dialog/GalleryPickerDialog.java	(revision 403)
+++ src/main/java/org/onehippo/addon/frontend/gallerypicker/dialog/GalleryPickerDialog.java	(working copy)
@@ -1,19 +1,55 @@
+/*
+ * Copyright 2013 Hippo B.V. (http://www.onehippo.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.onehippo.addon.frontend.gallerypicker.dialog;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.rmi.RemoteException;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.ItemNotFoundException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.wicket.Component;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.Session;
+import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
 import org.apache.wicket.ajax.AjaxEventBehavior;
 import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
 import org.apache.wicket.ajax.markup.html.form.AjaxButton;
 import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.DropDownChoice;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.upload.FileUpload;
 import org.apache.wicket.markup.html.form.upload.FileUploadField;
 import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
 import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
 import org.apache.wicket.protocol.http.WebRequestCycle;
 import org.hippoecm.frontend.editor.plugins.linkpicker.LinkPickerDialog;
+import org.hippoecm.frontend.i18n.types.TypeChoiceRenderer;
 import org.hippoecm.frontend.plugin.IPluginContext;
 import org.hippoecm.frontend.plugin.config.IPluginConfig;
 import org.hippoecm.frontend.plugins.gallery.model.DefaultGalleryProcessor;
@@ -21,30 +57,41 @@
 import org.hippoecm.frontend.plugins.gallery.model.GalleryProcessor;
 import org.hippoecm.frontend.service.ISettingsService;
 import org.hippoecm.frontend.session.UserSession;
-import org.hippoecm.repository.api.*;
+import org.hippoecm.repository.api.Document;
+import org.hippoecm.repository.api.HippoNode;
+import org.hippoecm.repository.api.MappingException;
+import org.hippoecm.repository.api.StringCodec;
+import org.hippoecm.repository.api.StringCodecFactory;
+import org.hippoecm.repository.api.WorkflowException;
+import org.hippoecm.repository.api.WorkflowManager;
 import org.hippoecm.repository.gallery.GalleryWorkflow;
 import org.hippoecm.repository.standardworkflow.DefaultWorkflow;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
 /**
  * @version $Id$
  */
 public class GalleryPickerDialog extends LinkPickerDialog {
     @SuppressWarnings({"UnusedDeclaration"})
     private static Logger log = LoggerFactory.getLogger(GalleryPickerDialog.class);
+    private static final String GALLERY_TYPE_SELECTOR_ID = "galleryType";
+    private boolean uploadSelected;
+    private Component uploadTypeSelector;
+    private AjaxButton uploadButton;
+    private final LoadableDetachableModel<List<String>> galleryTypesModel;
+    private String galleryType;
 
-
     public GalleryPickerDialog(IPluginContext context, IPluginConfig config, IModel<String> model) {
         super(context, config, model);
 
+        galleryTypesModel = new LoadableDetachableModel<List<String>>() {
+            @Override
+            protected List<String> load() {
+                return loadGalleryTypes();
+            }
+        };
+
         Fragment fragment;
 
         if (config.getAsBoolean("enable.upload", false)) {
@@ -56,6 +103,29 @@
         add(fragment);
     }
 
+    /**
+     * This is the callback to enable/disable the OK button of the image browser dialog.
+     * We abuse it here as a signal that a new folder may have been selected. If so, the
+     * drop-down menu for selecting the target gallery type for uploaded images may need to
+     * be adjusted.
+     *
+     * @param isset
+     */
+    @Override
+    protected void setOkEnabled(boolean isset) {
+        super.setOkEnabled(isset);
+
+        // function is called by parent constructor, when our constructor hasn't run yet...
+        if (uploadTypeSelector != null && uploadButton != null) {
+
+            AjaxRequestTarget target = AjaxRequestTarget.get();
+            if (target != null) {
+                target.addComponent(uploadTypeSelector);
+                target.addComponent(uploadButton);
+            }
+        }
+    }
+
     @SuppressWarnings("unchecked")
     private Fragment createUploadForm(final IPluginConfig config) {
         Fragment fragment = new Fragment("fragment", "upload-fragment", this);
@@ -66,10 +136,23 @@
         final FileUploadField uploadField = new FileUploadField("uploadField");
         uploadField.setOutputMarkupId(true);
 
-        final AjaxButton uploadButton = new AjaxButton("uploadButton", uploadForm) {
+        // we use a container to enable Ajax-based (in)visibility while not meddling with the selected upload file.
+        uploadTypeSelector = new WebMarkupContainer("uploadTypeSelector").add(createTypeSelector());
+        uploadTypeSelector.setOutputMarkupId(true);
+
+        uploadButton = new AjaxButton("uploadButton", uploadForm) {
             private static final long serialVersionUID = 1L;
 
             @Override
+            public boolean isEnabled() {
+                if (uploadSelected) {
+                    List<String> galleryTypes = galleryTypesModel.getObject();
+                    return galleryTypes.size() > 0; // disable upload if the current folder has no gallery types at all
+                }
+                return false;
+            }
+
+            @Override
             protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
 
                 final FileUpload upload = uploadField.getFileUpload();
@@ -88,12 +171,11 @@
                             Node folderNode = getFolderModel().getObject();
 
                             //TODO replace shortcuts with custom workflow category(?)
-                            GalleryWorkflow workflow = (GalleryWorkflow) manager.getWorkflow("shortcuts", folderNode);
+                            GalleryWorkflow workflow = (GalleryWorkflow) manager.getWorkflow("gallery", folderNode);
                             String nodeName = getNodeNameCodec().encode(filename);
                             String localName = getLocalizeCodec().encode(filename);
-                            List<String> galleryTypes = workflow.getGalleryTypes();
-                            Document document = workflow.createGalleryItem(nodeName, galleryTypes.get(0));
-                            node = (HippoNode) (((UserSession) Session.get())).getJcrSession().getNodeByUUID(document.getIdentity());
+                            Document document = workflow.createGalleryItem(nodeName, galleryType);
+                            node = (HippoNode) UserSession.get().getJcrSession().getNodeByIdentifier(document.getIdentity());
                             DefaultWorkflow defaultWorkflow = (DefaultWorkflow) manager.getWorkflow("core", node);
                             if (!node.getLocalizedName().equals(localName)) {
                                 defaultWorkflow.localizeName(localName);
@@ -153,16 +235,17 @@
 
             @Override
             protected void onEvent(AjaxRequestTarget target) {
-                uploadButton.setEnabled(true);
+                uploadSelected = true;
                 target.addComponent(uploadButton);
             }
         });
-        uploadButton.setEnabled(false);
+        uploadSelected = false;
+
         uploadForm.add(uploadField);
+        uploadForm.add(uploadTypeSelector);
         uploadForm.add(uploadButton);
 
         fragment.add(uploadForm);
-        //add(uploadForm);
 
         //OMG: ugly workaround.. Input[type=file] is rendered differently on OSX in all browsers..
         WebRequestCycle requestCycle = (WebRequestCycle) RequestCycle.get();
@@ -196,4 +279,67 @@
         StringCodecFactory stringCodecFactory = settingsService.getStringCodecFactory();
         return stringCodecFactory.getStringCodec("encoding.display");
     }
+
+    private String getGalleryType() {
+        List<String> galleryTypes = galleryTypesModel.getObject();
+
+        if (galleryType == null || galleryTypes.indexOf(galleryType) < 0) {
+            galleryType = (galleryTypes.size() > 0) ? galleryTypes.get(0) : null;
+        } else {
+            // preserve old selected value
+        }
+        return galleryType;
+    }
+
+    /**
+     * Create the galleryTypeSelector, only shown in the UI if there actually is something to choose from.
+     * Send changes to the backend using Ajax, in order to remember old choices while navigating through the
+     * gallery.
+     *
+     * @return the type selector component
+     */
+    @SuppressWarnings("unchecked")
+    private Component createTypeSelector() {
+        getGalleryType(); // initialize the galleryType value
+        return new DropDownChoice<String>(GALLERY_TYPE_SELECTOR_ID, new PropertyModel(this, "galleryType"),
+                                          galleryTypesModel, new TypeChoiceRenderer(this)) {
+            @Override
+            public boolean isVisible() {
+                return getChoices().size() > 1;
+            }
+        }
+        .setNullValid(false)
+        .add(new AjaxFormComponentUpdatingBehavior("onchange") {
+            @Override
+            protected void onUpdate(AjaxRequestTarget target) {
+                // required because abstract, but all we need is to have galleryType set, which happens underwater.
+            }
+        });
+    }
+
+    /**
+     * Load gallery types from repo-based configuration (target folder)
+     * @return list of supported type names for the current folder.
+     */
+    private List<String> loadGalleryTypes() {
+        List<String> types = new ArrayList<String>();
+        WorkflowManager manager = UserSession.get().getWorkflowManager();
+
+        try {
+            //Get the selected folder from the folderReference Service
+            Node folderNode = getFolderModel().getObject();
+            GalleryWorkflow workflow = (GalleryWorkflow) manager.getWorkflow("gallery", folderNode);
+            types = workflow.getGalleryTypes();
+        } catch (RemoteException e) {
+            log.error("", e);
+        } catch (MappingException e) {
+            log.error("", e);
+        } catch (ItemNotFoundException e) {
+            log.error("", e);
+        } catch (RepositoryException e) {
+            log.error("", e);
+        }
+
+        return types;
+    }
 }
Index: src/main/java/org/onehippo/addon/frontend/gallerypicker/dialog/GalleryPickerDialog.html
===================================================================
--- src/main/java/org/onehippo/addon/frontend/gallerypicker/dialog/GalleryPickerDialog.html	(revision 403)
+++ src/main/java/org/onehippo/addon/frontend/gallerypicker/dialog/GalleryPickerDialog.html	(working copy)
@@ -36,6 +36,7 @@
                             <wicket:message key="select-file-label"/>
                         </label>
                         <input wicket:id="uploadField" size="60" id="upload" type="file" class="browse-button"/>
+                        <span wicket:id="uploadTypeSelector"><select wicket:id="galleryType" id="typeselect"/></span>
                         <input wicket:id="uploadButton" type="submit" value="Upload" class="upload-button"/>
                     </div>
                 </form>
