This is an automated email from the ASF dual-hosted git repository.

snoopdave pushed a commit to branch media-library
in repository https://gitbox.apache.org/repos/asf/roller.git

commit 577b404af3bd982bd77b1a5f8ba257a837374172
Author: David M. Johnson <[email protected]>
AuthorDate: Sun Oct 25 13:48:49 2026 -0400

    Media chooser on the shared card; description as alt text
    
    The entry editor's media chooser uses the library's card and query: a
    page of a folder, newest first, with a name search and the shared pager.
    Inserting an image uses its description as the alt text (the file name
    when there is none), and the editor builds the inserted markup with DOM
    APIs, so names and descriptions are escaped. Create entry escapes them
    too. The description field is labeled as the alt text.
    
    The upload success page shows readable sizes and no longer shows pixel
    dimensions for non-images. Old media styles are removed, and the user
    guide describes the new library, upload, details and chooser.
---
 .../ui/struts2/editor/EntryAddWithMediaFile.java   | 328 +++++++++++----------
 .../ui/struts2/editor/MediaFileImageChooser.java   |  94 +++---
 .../main/resources/ApplicationResources.properties |   5 +-
 .../webapp/WEB-INF/jsps/editor/EntryEditor.jsp     |  11 +-
 .../webapp/WEB-INF/jsps/editor/MediaFileAdd.jsp    |   2 +-
 .../WEB-INF/jsps/editor/MediaFileAddSuccess.jsp    |  19 +-
 .../webapp/WEB-INF/jsps/editor/MediaFileCard.jsp   |  43 ++-
 .../webapp/WEB-INF/jsps/editor/MediaFileEdit.jsp   |   3 +-
 .../WEB-INF/jsps/editor/MediaFileImageChooser.jsp  | 157 ++++------
 app/src/main/webapp/roller-ui/styles/roller.css    |  77 +----
 docs/roller-user-guide.adoc                        | 129 ++++----
 11 files changed, 427 insertions(+), 441 deletions(-)

diff --git 
a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
 
b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
index d224363f6..1d37491e3 100644
--- 
a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
+++ 
b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
@@ -1,76 +1,77 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  The ASF licenses this file to You
- * 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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.roller.weblogger.ui.struts2.editor;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.business.MediaFileManager;
-import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.pojos.MediaFile;
-import org.apache.struts2.convention.annotation.AllowedMethods;
-import org.apache.struts2.interceptor.parameter.StrutsParameter;
-import org.apache.struts2.interceptor.validation.SkipValidation;
-
-/**
- * Prepares creation of a new weblog entry with an embedded pointer to a media 
file.
- */
-@SuppressWarnings("serial")
-// TODO: make this work @AllowedMethods({"execute"})
-public class EntryAddWithMediaFile extends MediaFileBase {
-
-    private static Log log = LogFactory.getLog(EntryAddWithMediaFile.class);
-
-    // bean for managing form data
-    private EntryBean bean = new EntryBean();
-
-    private String   weblog = null;
-    // used by MediaFileView.jsp: multiple images and optional enclosure URL 
to create a blog post
-    private String[] selectedImages = null;
-    // used by MediaFileView.jsp: single image to create a blog post
-    private String   selectedImage = null;
-    
-
-    public EntryAddWithMediaFile() {
-        this.actionName = "entryAdd";
-        this.desiredMenu = "editor";
-        this.pageTitle = "weblogEdit.title.newEntry";
-    }
-
-    /**
-     * Prepare bean for creating a new weblog entry with a link to a media 
file.
-     * @return String The result of the action.
-     */
-    @SkipValidation
-    @Override
-    public String execute() {
-        MediaFileManager manager =
-             WebloggerFactory.getWeblogger().getMediaFileManager();
-        try {
-
-            if (StringUtils.isNotEmpty(selectedImage) && selectedImages == 
null) {
-                selectedImages = new String[1];
-                selectedImages[0] = selectedImage;
-            }
-
-            StringBuilder sb = new StringBuilder();
-
-            if (selectedImages != null) {
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.roller.weblogger.ui.struts2.editor;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.StringEscapeUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.business.MediaFileManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.pojos.MediaFile;
+import org.apache.struts2.convention.annotation.AllowedMethods;
+import org.apache.struts2.interceptor.parameter.StrutsParameter;
+import org.apache.struts2.interceptor.validation.SkipValidation;
+
+/**
+ * Prepares creation of a new weblog entry with an embedded pointer to a media 
file.
+ */
+@SuppressWarnings("serial")
+// TODO: make this work @AllowedMethods({"execute"})
+public class EntryAddWithMediaFile extends MediaFileBase {
+
+    private static Log log = LogFactory.getLog(EntryAddWithMediaFile.class);
+
+    // bean for managing form data
+    private EntryBean bean = new EntryBean();
+
+    private String   weblog = null;
+    // used by MediaFileView.jsp: multiple images and optional enclosure URL 
to create a blog post
+    private String[] selectedImages = null;
+    // used by MediaFileView.jsp: single image to create a blog post
+    private String   selectedImage = null;
+    
+
+    public EntryAddWithMediaFile() {
+        this.actionName = "entryAdd";
+        this.desiredMenu = "editor";
+        this.pageTitle = "weblogEdit.title.newEntry";
+    }
+
+    /**
+     * Prepare bean for creating a new weblog entry with a link to a media 
file.
+     * @return String The result of the action.
+     */
+    @SkipValidation
+    @Override
+    public String execute() {
+        MediaFileManager manager =
+             WebloggerFactory.getWeblogger().getMediaFileManager();
+        try {
+
+            if (StringUtils.isNotEmpty(selectedImage) && selectedImages == 
null) {
+                selectedImages = new String[1];
+                selectedImages[0] = selectedImage;
+            }
+
+            StringBuilder sb = new StringBuilder();
+
+            if (selectedImages != null) {
                 for (String image : selectedImages) {
                     MediaFile mediaFile = 
manager.getMediaFile(getActionWeblog(), image);
                     if (mediaFile == null) {
@@ -78,99 +79,100 @@ public class EntryAddWithMediaFile extends MediaFileBase {
                         return ERROR;
                     }
                     String link;
-
-                    if (mediaFile.isImageFile()) {
-                        link = "<p>" + mediaFile.getName() + "</p>";
-                        link += "<a href=\"<url>\"><img src=\"<urlt>\" 
alt=\"<name>\" width=\"<width>\" height=\"<height>\"></img></a>";
-                        link = link.replace("<url>", mediaFile.getPermalink())
-                                   .replace("<urlt>", 
mediaFile.getThumbnailURL())
-                                   .replace("<name>", mediaFile.getName())
-                                   .replace("<width>", 
""+mediaFile.getThumbnailWidth())
-                                   .replace("<height>", 
""+mediaFile.getThumbnailHeight());
-                    } else {
-                        link = "<a href=\"<url>\"><name></a> (<size> bytes, 
<type>)";
-                        link = link.replace("<url>", mediaFile.getPermalink())
-                                   .replace("<name>", mediaFile.getName())
-                                   .replace("<size>",""+mediaFile.getLength())
-                                   
.replace("<type>",mediaFile.getContentType());
-                    }
-                    sb.append(link);
-                }
-            }
-
-            if (!StringUtils.isEmpty(bean.getEnclosureURL())) {
-                sb.append("<p>")
-                  .append(getText("mediaFileEdit.includesEnclosure"))
-                  .append("<br />")
-                  .append("<a href=\"" + bean.getEnclosureURL() + "\">")
-                  .append(bean.getEnclosureURL())
-                  .append("</a></p>");
-            }
-
-            bean.setText(sb.toString());
-
+
+                    // escaped: names and descriptions are author text
+                    String name = 
StringEscapeUtils.escapeHtml4(mediaFile.getName());
+                    if (mediaFile.isImageFile()) {
+                        String alt = 
StringUtils.isNotBlank(mediaFile.getDescription())
+                                ? mediaFile.getDescription().trim() : 
mediaFile.getName();
+                        link = "<p>" + name + "</p>"
+                                + "<a href=\"" + 
StringEscapeUtils.escapeHtml4(mediaFile.getPermalink()) + "\">"
+                                + "<img src=\"" + 
StringEscapeUtils.escapeHtml4(mediaFile.getThumbnailURL())
+                                + "\" alt=\"" + 
StringEscapeUtils.escapeHtml4(alt)
+                                + "\" width=\"" + mediaFile.getThumbnailWidth()
+                                + "\" height=\"" + 
mediaFile.getThumbnailHeight() + "\"></a>";
+                    } else {
+                        link = "<a href=\"" + 
StringEscapeUtils.escapeHtml4(mediaFile.getPermalink()) + "\">"
+                                + name + "</a> (" + mediaFile.getLength() + " 
bytes, "
+                                + 
StringEscapeUtils.escapeHtml4(mediaFile.getContentType()) + ")";
+                    }
+                    sb.append(link);
+                }
+            }
+
+            if (!StringUtils.isEmpty(bean.getEnclosureURL())) {
+                sb.append("<p>")
+                  .append(getText("mediaFileEdit.includesEnclosure"))
+                  .append("<br />")
+                  .append("<a href=\"" + 
StringEscapeUtils.escapeHtml4(bean.getEnclosureURL()) + "\">")
+                  
.append(StringEscapeUtils.escapeHtml4(bean.getEnclosureURL()))
+                  .append("</a></p>");
+            }
+
+            bean.setText(sb.toString());
+
         } catch (Exception e) {
             log.error("Error while constructing media file link for new 
entry", e);
             addError("MediaFile.error.view");
             return ERROR;
         }
         return SUCCESS;
-    }
-
-    @StrutsParameter(depth = 1)
-    public EntryBean getBean() {
-        return bean;
-    }
-
-    public void setBean(EntryBean bean) {
-        this.bean = bean;
-    }
-
-    /**
-     * @return the selectedImages
-     */
-    public String[] getSelectedImages() {
-        return selectedImages;
-    }
-
-    /**
-     * @param selectedImages the selectedImages to set
-     */
-    @StrutsParameter
-    public void setSelectedImages(String[] selectedImages) {
-        this.selectedImages = selectedImages;
-    }
-
-    /**
-     * @return the weblog
-     */
-    @Override
-    public String getWeblog() {
-        return weblog;
-    }
-
-    /**
-     * @param weblog the weblog to set
-     */
-    @Override
-    @StrutsParameter
-    public void setWeblog(String weblog) {
-        this.weblog = weblog;
-    }
-
-    /**
-     * @return the selectedImage
-     */
-    public String getSelectedImage() {
-        return selectedImage;
-    }
-
-    /**
-     * @param selectedImage the selectedImage to set
-     */
-    @StrutsParameter
-    public void setSelectedImage(String selectedImage) {
-        this.selectedImage = selectedImage;
-    }
-
-}
+    }
+
+    @StrutsParameter(depth = 1)
+    public EntryBean getBean() {
+        return bean;
+    }
+
+    public void setBean(EntryBean bean) {
+        this.bean = bean;
+    }
+
+    /**
+     * @return the selectedImages
+     */
+    public String[] getSelectedImages() {
+        return selectedImages;
+    }
+
+    /**
+     * @param selectedImages the selectedImages to set
+     */
+    @StrutsParameter
+    public void setSelectedImages(String[] selectedImages) {
+        this.selectedImages = selectedImages;
+    }
+
+    /**
+     * @return the weblog
+     */
+    @Override
+    public String getWeblog() {
+        return weblog;
+    }
+
+    /**
+     * @param weblog the weblog to set
+     */
+    @Override
+    @StrutsParameter
+    public void setWeblog(String weblog) {
+        this.weblog = weblog;
+    }
+
+    /**
+     * @return the selectedImage
+     */
+    public String getSelectedImage() {
+        return selectedImage;
+    }
+
+    /**
+     * @param selectedImage the selectedImage to set
+     */
+    @StrutsParameter
+    public void setSelectedImage(String selectedImage) {
+        this.selectedImage = selectedImage;
+    }
+
+}
diff --git 
a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java
 
b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java
index 172acdf4f..e295017de 100644
--- 
a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java
+++ 
b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java
@@ -19,20 +19,26 @@ package org.apache.roller.weblogger.ui.struts2.editor;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.business.FileIOException;
 import org.apache.roller.weblogger.business.MediaFileManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.MediaFile;
-import org.apache.roller.weblogger.pojos.MediaFileComparator;
-import 
org.apache.roller.weblogger.pojos.MediaFileComparator.MediaFileComparatorType;
 import org.apache.roller.weblogger.pojos.MediaFileDirectory;
 import org.apache.roller.weblogger.pojos.MediaFileDirectoryComparator;
 import 
org.apache.roller.weblogger.pojos.MediaFileDirectoryComparator.DirectoryComparatorType;
+import org.apache.roller.weblogger.pojos.MediaFileFilter;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
+import org.apache.roller.weblogger.ui.struts2.pagers.MediaFilePager;
 import org.apache.roller.weblogger.ui.struts2.util.KeyValueObject;
+import org.apache.roller.weblogger.util.URLUtilities;
 import org.apache.struts2.convention.annotation.AllowedMethods;
 import org.apache.struts2.interceptor.parameter.StrutsParameter;
 import org.apache.struts2.interceptor.validation.SkipValidation;
@@ -51,6 +57,10 @@ public class MediaFileImageChooser extends MediaFileBase {
     private List<MediaFile> childFiles;
     private MediaFileDirectory currentDirectory;
 
+    // name search and page; the chooser always shows one folder, newest first
+    private MediaFileSearchBean bean = new MediaFileSearchBean();
+    private MediaFilePager pager;
+
     public MediaFileImageChooser() {
         this.actionName = "mediaFileImageChooser";
         this.desiredMenu = "editor";
@@ -76,55 +86,73 @@ public class MediaFileImageChooser extends MediaFileBase {
      * 
      * @return String The result of the action.
      */
+    /**
+     * Shows a page of a folder's files, newest first, optionally only those
+     * whose name starts with the search text. Same query as the library.
+     */
     @SkipValidation
     @Override
     public String execute() {
         MediaFileManager manager = 
WebloggerFactory.getWeblogger().getMediaFileManager();
         try {
-
-            MediaFileDirectory directory;
-            if (this.directoryId != null) {
+            MediaFileDirectory directory = null;
+            if (StringUtils.isNotEmpty(this.directoryId)) {
                 directory = manager.getMediaFileDirectory(getActionWeblog(), 
this.directoryId);
-            } else if (this.directoryName != null) {
+            } else if (StringUtils.isNotEmpty(this.directoryName)) {
                 directory = 
manager.getMediaFileDirectoryByName(getActionWeblog(), this.directoryName);
-                this.directoryId = directory.getId();
-            } else {
+            }
+            if (directory == null) {
                 directory = 
manager.getDefaultMediaFileDirectory(getActionWeblog());
-                this.directoryId = directory.getId();
             }
-
-            this.childFiles = new ArrayList<>();
-            this.childFiles.addAll(directory.getMediaFiles());
-            this.childFiles.sort(new MediaFileComparator( 
MediaFileComparatorType.NAME));
             this.currentDirectory = directory;
-
-            // List of available directories
-            List<MediaFileDirectory> sortedDirList = new ArrayList<>();
-            List<MediaFileDirectory> directories = 
manager.getMediaFileDirectories(getActionWeblog());
-            for (MediaFileDirectory mediaFileDirectory : directories) {
-                if (!"default".equals(mediaFileDirectory.getName()) || 
!"default".equals(directory.getName())) {
-                    sortedDirList.add(mediaFileDirectory);
-                }
-            }
-
-            sortedDirList.sort(new MediaFileDirectoryComparator(
-                DirectoryComparatorType.NAME));
+            this.directoryId = directory.getId();
+
+            bean.setSortBy(MediaFileSearchBean.SORT_NEWEST);
+            bean.setScope(MediaFileSearchBean.SCOPE_FOLDER);
+            MediaFileFilter filter = new MediaFileFilter();
+            bean.copyTo(filter);
+            filter.setDirectory(directory);
+
+            long totalCount = manager.getMediaFileCount(getActionWeblog(), 
filter);
+            this.childFiles = new 
ArrayList<>(manager.searchMediaFiles(getActionWeblog(), filter));
+
+            Map<String, String> params = new LinkedHashMap<>();
+            params.put("weblog", getActionWeblog().getHandle());
+            params.put("directoryId", directoryId);
+            params.putAll(bean.toParams());
+            String baseUrl = WebloggerRuntimeConfig.getRelativeContextURL()
+                    + "/roller-ui/authoring/overlay/mediaFileImageChooser.rol?"
+                    + params.entrySet().stream()
+                        .map(e -> e.getKey() + "=" + 
URLUtilities.encode(e.getValue()))
+                        .collect(Collectors.joining("&"));
+            this.pager = new MediaFilePager(baseUrl, bean.getPage(), 
childFiles, totalCount,
+                    MediaFileSearchBean.PAGE_SIZE);
+
+            List<MediaFileDirectory> sortedDirList = new ArrayList<>(
+                    manager.getMediaFileDirectories(getActionWeblog()));
+            sortedDirList.sort(new 
MediaFileDirectoryComparator(DirectoryComparatorType.NAME));
             setAllDirectories(sortedDirList);
 
-            return SUCCESS;
-
         } catch (Exception ex) {
             log.error("Error viewing media file directory ", ex);
             addError("MediaFile.error.view");
-
         }
         return SUCCESS;
     }
 
-    /**
-     * Returns the hierarchy of the current directory. This is useful in
-     * displaying path information as breadcrumb.
-     */
+    public MediaFilePager getPager() {
+        return pager;
+    }
+
+    @StrutsParameter(depth = 1)
+    public MediaFileSearchBean getBean() {
+        return bean;
+    }
+
+    public void setBean(MediaFileSearchBean bean) {
+        this.bean = bean;
+    }
+
     public List<KeyValueObject> getCurrentDirectoryHierarchy() {
         List<KeyValueObject> directoryHierarchy = new ArrayList<>();
 
diff --git a/app/src/main/resources/ApplicationResources.properties 
b/app/src/main/resources/ApplicationResources.properties
index 4e089ead8..2cef04545 100644
--- a/app/src/main/resources/ApplicationResources.properties
+++ b/app/src/main/resources/ApplicationResources.properties
@@ -770,7 +770,8 @@ maintenance.message.reset=Successfully reset the hit count 
of your Roller weblog
 # ----------------------------------------------------------- Media file 
management
 
 mediaFileImageChooser.subtitle=Choose a Media File to be inserted
-mediaFileImageChooser.pageTip=Select an image and it will be included as a 
thumbnail, or select a file and it will be included as a link.
+mediaFileImageChooser.pageTip=Choose an image to insert it as a thumbnail, or 
a file to insert a link to it. An image gets its description as alt text.
+mediaFileImageChooser.insert=Insert {0}
 
 # -- Media File Add
 
@@ -932,6 +933,8 @@ mediaFileView.listView=List
 mediaFileView.sortNewest=Newest first
 mediaFileView.sortOldest=Oldest first
 mediaFileEdit.title=Media file details
+mediaFileEdit.descriptionAlt=Description (used as alt text)
+mediaFileEdit.descriptionAltHelp=Describe what the image shows, for readers 
who cannot see it. The editor uses it as the alt text when you insert the image.
 mediaFileEdit.backToLibrary=Back to the media library
 mediaFileEdit.dimensions=Dimensions
 mediaFileEdit.pixels={0} \u00d7 {1} pixels
diff --git a/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp 
b/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp
index 5e7e8999e..9eb73800d 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp
@@ -212,14 +212,19 @@
         $("#mediaFileEditor").attr('src', 'about:blank');
     }
 
-    function onSelectMediaFile(name, url, isImage) {
+    // Called by the media chooser. The markup is built with DOM APIs, so 
names,
+    // descriptions and URLs are escaped. The alt text is the file's 
description,
+    // or its name when it has none.
+    function onSelectMediaFile(name, url, isImage, alt) {
         $("#mediafile_edit_lightbox").modal("hide");
         $("#mediaFileEditor").attr('src', 'about:blank');
+        var link = $('<a>').attr('href', url);
         if (isImage === "true") {
-            insertMediaFile('<a href="' + url + '"><img src="' + url + 
'?t=true" alt="' + name + '" /></a>');
+            link.append($('<img>').attr({src: url + '?t=true', alt: alt || 
name}));
         } else {
-            insertMediaFile('<a href="' + url + '">' + name + '</a>');
+            link.text(name);
         }
+        insertMediaFile(link.prop('outerHTML'));
     }
 
 </script>
diff --git a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileAdd.jsp 
b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileAdd.jsp
index 87a909044..1af40760c 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileAdd.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileAdd.jsp
@@ -97,7 +97,7 @@
         <summary><s:text name="mediaFileAdd.shared"/></summary>
         <p class="form-text"><s:text name="mediaFileAdd.sharedHelp"/></p>
 
-        <label class="form-label" for="uploadDescription"><s:text 
name="generic.description"/></label>
+        <label class="form-label" for="uploadDescription"><s:text 
name="mediaFileEdit.descriptionAlt"/></label>
         <s:textarea id="uploadDescription" name="bean.description" rows="2" 
cssClass="form-control"/>
 
         <label class="form-label" for="uploadTags"><s:text 
name="mediaFileAdd.tags"/></label>
diff --git a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp 
b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
index 9ae9079d1..96d7cc8c8 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
@@ -59,12 +59,13 @@
                     <div class="row">
 
                         <div class="col-md-1">
-                            <input type="checkbox" name="selectedImages" 
value="<s:property value="#newImage.id"/>"/>
+                            <input type="checkbox" name="selectedImages" 
value="<s:property value="#newImage.id"/>"
+                                   class="form-check-input"
+                                   aria-label="<s:text 
name='mediaFileView.selectFile' escapeHtml='true'><s:param 
value='#newImage.name'/></s:text>"/>
                         </div>
 
                         <div class="col-md-2">
-                            <img align="center" class="mediaFileImage"
-                                 src='<s:property 
value="%{#newImage.thumbnailURL}" />' alt="thumbnail"/>
+                            <img class="mediaFileImage" src='<s:property 
value="%{#newImage.thumbnailURL}" />' alt=""/>
                         </div>
 
                         <div class="col-md-9">
@@ -80,9 +81,11 @@
 
                             <p>
                                 <b><s:text name="mediaFileSuccess.size"/></b>
-                                <s:property value="%{#newImage.length}"/> 
<s:text name="mediaFileSuccess.bytes"/>,
-                                <s:property value="%{#newImage.width}"/> x
-                                <s:property value="%{#newImage.height}"/> 
<s:text name="mediaFileSuccess.pixels"/>
+                                <s:property 
value="formatSize(#newImage.length)"/>,
+                                <s:text name="mediaFileEdit.pixels">
+                                    <s:param value="#newImage.width"/>
+                                    <s:param value="#newImage.height"/>
+                                </s:text>
                             </p>
 
                             <p>
@@ -131,9 +134,7 @@
                                 <s:property 
value="%{#newFile.contentType}"/>,&nbsp;
 
                                 <b><s:text name="mediaFileSuccess.size"/></b>
-                                <s:property value="%{#newFile.length}"/> 
<s:text name="mediaFileSuccess.bytes"/>,
-                                <s:property value="%{#newFile.width}"/> x
-                                <s:property value="%{#newFile.height}"/> 
<s:text name="mediaFileSuccess.pixels"/>
+                                <s:property 
value="formatSize(#newFile.length)"/>
                             </p>
 
                             <p>
diff --git a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileCard.jsp 
b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileCard.jsp
index e5ccaada2..b7e8a3049 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileCard.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileCard.jsp
@@ -17,10 +17,46 @@
 --%>
 <%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
 
-<%-- One media file in the library grid or list. Expects #mediaFile on the 
value stack and
-     libraryQuery on the action. The checkbox selects the file; the preview 
and name open its
-     details page, which links back to this library page. --%>
+<%-- One media file in the library grid or list, or in the editor's media 
chooser.
+     Expects #mediaFile on the value stack. In the library (libraryQuery on 
the action) the
+     checkbox selects the file and the preview and name open its details page, 
which links
+     back to this library page. In the chooser (#chooserMode set) the preview 
and name insert
+     the file into the entry, with its description as the alt text. --%>
 
+<s:if test="#chooserMode">
+    <s:set var="altText" value="(#mediaFile.description != null && 
!#mediaFile.description.trim().isEmpty()) ? #mediaFile.description.trim() : 
#mediaFile.name"/>
+<li class="media-card">
+    <button type="button" class="media-card-preview mediafile-select-target" 
tabindex="-1" aria-hidden="true"
+            data-mediafile-name="<s:property value='#mediaFile.name'/>"
+            data-mediafile-url="<s:property value='#mediaFile.permalink'/>"
+            data-mediafile-alt="<s:property value='#altText'/>"
+            data-mediafile-is-image="<s:property 
value='#mediaFile.imageFile'/>">
+        <s:if test="#mediaFile.imageFile">
+            <img src="<s:property value='#mediaFile.thumbnailURL'/>" alt="" 
loading="lazy"
+                 data-fallback-icon="<s:property 
value='typeIcon(#mediaFile.contentType)'/>"/>
+        </s:if>
+        <s:else>
+            <span class="bi <s:property 
value='typeIcon(#mediaFile.contentType)'/>" aria-hidden="true"></span>
+        </s:else>
+    </button>
+    <div class="media-card-body">
+        <div class="media-card-text">
+            <button type="button" class="media-card-name 
mediafile-select-target"
+                    data-mediafile-name="<s:property value='#mediaFile.name'/>"
+                    data-mediafile-url="<s:property 
value='#mediaFile.permalink'/>"
+                    data-mediafile-alt="<s:property value='#altText'/>"
+                    data-mediafile-is-image="<s:property 
value='#mediaFile.imageFile'/>"
+                    aria-label="<s:text name='mediaFileImageChooser.insert' 
escapeHtml='true'><s:param value='#mediaFile.name'/></s:text>"
+                    title="<s:property value='#mediaFile.name'/>"><s:property 
value="#mediaFile.name"/></button>
+            <span class="media-card-meta">
+                <span class="media-card-type"><s:property 
value="formatType(#mediaFile.contentType, #mediaFile.name)"/></span>
+                <span class="media-card-size"><s:property 
value="formatSize(#mediaFile.length)"/></span>
+            </span>
+        </div>
+    </div>
+</li>
+</s:if>
+<s:else>
 <s:url var="detailsURL" escapeAmp="false" action="mediaFileEdit">
     <s:param name="weblog" value="%{actionWeblog.handle}"/>
     <s:param name="mediaFileId" value="%{#mediaFile.id}"/>
@@ -56,3 +92,4 @@
     </div>
 
 </li>
+</s:else>
diff --git a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileEdit.jsp 
b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileEdit.jsp
index da247a3ad..510a10931 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileEdit.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileEdit.jsp
@@ -121,7 +121,8 @@
 
         <s:textfield name="bean.name" maxlength="255" 
label="%{getText('generic.name')}"/>
 
-        <s:textarea name="bean.description" rows="2" 
label="%{getText('generic.description')}"/>
+        <s:textarea name="bean.description" rows="2" 
label="%{getText('mediaFileEdit.descriptionAlt')}"
+                    tooltip="%{getText('mediaFileEdit.descriptionAltHelp')}"/>
 
         <s:textfield name="bean.tagsAsString" maxlength="255" 
label="%{getText('mediaFileEdit.tags')}"/>
 
diff --git a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp 
b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp
index cbe42cdd9..b1c365f75 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp
@@ -17,124 +17,73 @@
 --%>
 <%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
 
-<style>
+<%-- The entry editor's media chooser, shown in a dialog frame. A page of one 
folder's files,
+     newest first; choosing one calls the editor's onSelectMediaFile() with 
values from data-*
+     attributes (MediaFileCard.jsp, chooser mode). --%>
 
-</style>
-
-<script>
-    function onSelectDirectory(id) {
-        window.location = "?directoryId=" + id + "&weblog=" + '<s:property 
value="actionWeblog.handle" />';
-    }
-</script>
-
-
-<%-- ********************************************************************* --%>
-
-<%-- Subtitle and folder path --%>
-
-<s:if test="childFiles || allDirectories">
+<div class="media-chooser">
 
     <s:form id="mediaFileChooserForm" name="mediaFileChooserForm" 
action="mediaFileImageChooser"
-            theme="bootstrap" cssClass="form-vertical">
-        <s:hidden name="salt"/>
+            method="get" theme="simple" cssClass="media-chooser-search" 
role="search">
         <s:hidden name="weblog"/>
-        <input type="hidden" name="mediaFileId" value=""/>
-
-        <p class="pagetip"><s:text name="mediaFileImageChooser.pageTip"/></p>
-
-        <%-- ***************************************************************** 
--%>
-        <%-- Maybe show media directory selector --%>
-
-        <s:if test="!allDirectories.isEmpty">
-            <s:select name="directoryId" emptyOption="true" 
label="%{getText('mediaFileView.viewFolder')}"
-                      list="allDirectories" listKey="id" listValue="name" 
onchange="onView()"/>
-        </s:if>
-
-        <%-- ***************************************************************** 
--%>
-        <%-- Media files grid --%>
-
-        <div id="imageGrid" class="card">
-            <div class="card-body">
-
-                <ul>
-
-                    <s:if test="childFiles.size() == 0">
-                        <p style="text-align: center"><s:text 
name="mediaFileView.noFiles"/></p>
-                    </s:if>
-
-                    <s:if test="childFiles.size() > 0">
-
-                        <s:iterator var="mediaFile" value="childFiles">
-
-                            <s:url var="mediaFileURL" includeContext="false" 
value="%{#mediaFile.permalink}"/>
-                            <s:url var="mediaFileThumbnailURL" 
value="%{#mediaFile.thumbnailURL}"/>
-
-                            <li class="align-images"
-                                onmouseover="highlight(this, true)" 
onmouseout="highlight(this, false)">
-
-                                <div class="mediaObject 
mediafile-select-target"
-                                     data-mediafile-name="<s:property 
value="#mediaFile.name"/>"
-                                     data-mediafile-url="<s:property 
value="%{mediaFileURL}"/>"
-                                     data-mediafile-is-image="<s:property 
value="#mediaFile.isImageFile()"/>">
-
-                                    <s:if test="#mediaFile.imageFile">
-                                        <img border="0" src="<s:property 
value='%{mediaFileThumbnailURL}' />"
-                                             width="<s:property 
value='#mediaFile.thumbnailWidth'/>"
-                                             height="<s:property 
value='#mediaFile.thumbnailHeight'/>"
-                                             alt="<s:property 
value='#mediaFile.name' />"/>
-                                    </s:if>
-
-                                    <s:else>
-                                        <span class="bi 
bi-file-earmark"></span>
-                                    </s:else>
-
-                                </div>
-
-                                <div class="mediaObjectInfo">
-                                    <str:truncateNicely upper="60">
-                                        <s:property value="#mediaFile.name"/>
-                                    </str:truncateNicely>
-                                </div>
-
-                            </li>
-
-                        </s:iterator>
-                    </s:if>
-
-                </ul>
-            </div>
+        <div>
+            <label class="form-label" for="chooserFolder"><s:text 
name="mediaFileView.viewFolder"/></label>
+            <s:select id="chooserFolder" name="directoryId" 
list="allDirectories" listKey="id" listValue="name"
+                      cssClass="form-select"/>
+        </div>
+        <div class="media-chooser-name">
+            <label class="form-label" for="chooserName"><s:text 
name="mediaFileView.nameStartsWith"/></label>
+            <s:textfield id="chooserName" name="bean.name" maxlength="255" 
cssClass="form-control"/>
+        </div>
+        <div>
+            <button type="submit" class="btn btn-primary"><s:text 
name="generic.search"/></button>
         </div>
-
-        <div style="clear:left;"></div>
-
     </s:form>
 
-</s:if>
+    <p class="pagetip"><s:text name="mediaFileImageChooser.pageTip"/></p>
+
+    <s:if test="childFiles.size() > 0">
+        <s:include value="/WEB-INF/jsps/editor/Pager.jsp"/>
+        <s:set var="chooserMode" value="true"/>
+        <ul class="media-grid">
+            <s:iterator var="mediaFile" value="childFiles">
+                <s:include value="/WEB-INF/jsps/editor/MediaFileCard.jsp"/>
+            </s:iterator>
+        </ul>
+        <s:include value="/WEB-INF/jsps/editor/Pager.jsp"/>
+    </s:if>
+    <s:else>
+        <div class="media-empty">
+            <span class="bi bi-images" aria-hidden="true"></span>
+            <p><s:if test="bean.search"><s:text 
name="mediaFileView.noResults"/></s:if>
+               <s:else><s:text name="mediaFileView.noFiles"/></s:else></p>
+        </div>
+    </s:else>
 
+</div>
 
 <script>
-
-    function onSelectMediaFile(name, url, isImage) {
-        window.parent.onSelectMediaFile(name, url, isImage);
-    }
-
     // Values come from data-* attributes and are bound via delegated 
listeners.
     $(document).on('click', '.mediafile-select-target', function () {
-        onSelectMediaFile($(this).attr('data-mediafile-name'),
+        window.parent.onSelectMediaFile($(this).attr('data-mediafile-name'),
                 $(this).attr('data-mediafile-url'),
-                $(this).attr('data-mediafile-is-image'));
+                $(this).attr('data-mediafile-is-image'),
+                $(this).attr('data-mediafile-alt'));
     });
 
-    function highlight(el, flag) {
-        if (flag) {
-            $(el).addClass("highlight");
-        } else {
-            $(el).removeClass("highlight");
-        }
-    }
-
-    function onView() {
-        document.mediaFileChooserForm.submit();
-    }
+    $('#chooserFolder').on('change', function () {
+        $('#chooserName').val('');
+        this.form.submit();
+    });
 
+    // A thumbnail that fails to load shows the file type icon instead.
+    document.addEventListener('error', function (e) {
+        var img = e.target;
+        if (img.tagName === 'IMG' && img.closest('.media-card-preview')) {
+            var icon = document.createElement('span');
+            icon.className = 'bi ' + (img.getAttribute('data-fallback-icon') 
|| 'bi-file-earmark');
+            icon.setAttribute('aria-hidden', 'true');
+            img.replaceWith(icon);
+        }
+    }, true);
 </script>
diff --git a/app/src/main/webapp/roller-ui/styles/roller.css 
b/app/src/main/webapp/roller-ui/styles/roller.css
index 0dc6d0834..a6c60f952 100644
--- a/app/src/main/webapp/roller-ui/styles/roller.css
+++ b/app/src/main/webapp/roller-ui/styles/roller.css
@@ -948,79 +948,24 @@ body {
     }
 }
 
-/* media files: legacy rules, still used by the editor's media chooser */
-
-.align-images {
-    display:inline;
-    float:left;
-    margin:5px;
-    list-style-type:none;
-    width:140px;
-    max-height:200px;
-    border: 1px solid #ccc;
-    text-align: center;
-}
-
-#sortByMenu {
-    width: 15em;
-}
-
-#viewDirectoryMenu {
-    width: 15em;
-}
-
-#moveTargetMenu {
-    width: 15em;
-}
-
-.mediaObject {
-    width:120px;
-    max-height:120px;
-    margin-top: 10px;
-    margin-left: 10px;
-}
-
-.mediaObjectInfo {
-    font-size:11px;
-}
-
-span.glyphicon-file {
-    font-size: 6em;
-}
+/* media chooser in the entry editor (MediaFileImageChooser.jsp) */
 
-.highlight {
-    border: 3px solid #aaa;
-}
-
-span.button {
-    height:15px;
-    width:15px;
-    float:right;
-}
-
-.sortByMenu, .viewDirectoryMenu {
-    display: inline;
-}
-
-#imageGrid {
-    display: block;
-    overflow: auto;
-    margin: 1em 0 1em 0;
+.media-chooser-search {
+    display: flex;
+    flex-wrap: wrap;
+    align-items: flex-end;
+    gap: 0.75rem;
+    margin-bottom: 0.75rem;
 }
 
-#imageGrid > div > ul {
-    padding-left:0;
+.media-chooser-name {
+    flex: 1 1 12rem;
 }
 
-div.image-controls,
-div.image-controls div,
-div.image-controls span,
-div.image-controls select,
-div.image-controls input {
-    display: inline;
+.mediaFileImage {
+    max-width: 100%;
 }
 
-
 /* theme edit */
 
 .row-display-flex {
diff --git a/docs/roller-user-guide.adoc b/docs/roller-user-guide.adoc
index cd47d0d6e..215d150ae 100644
--- a/docs/roller-user-guide.adoc
+++ b/docs/roller-user-guide.adoc
@@ -424,86 +424,101 @@ limit. To accept larger pasted images, set `maxPostSize` 
on the Tomcat
 entry text.
 
 If you’d like to upload images or other files for use in your weblog, go
-to your weblog’s *Create & Edit -> Media Files* page. From there you can
-upload files, browse and search files. You can also manage your files,
-organize them into directories and post them to your weblog.
-
-image::user-guide-12-media.png[]
+to your weblog’s *Create & Edit -> Media Files* page, the media library.
+From there you can upload, find and organize files, and post them to your
+weblog.
 
-You can see the Media File View page above. Below we’ll discuss all of
-the things you can do with Media Files via the Media File View page and
-the new Media File browser that we’ve added to the Weblog Editor.
+The library shows one folder at a time. The folders are listed on the left;
+on a narrow screen, choose the folder from the list at the top instead. Files
+show as a grid of previews, or as a list with name, type, size and upload
+date; use the buttons next to *Sort by* to switch. Your choice is kept in
+your browser. The library shows 48 files a page, newest first. Use *Sort by*
+to sort by oldest first, name or type, and the buttons above and below the
+files to move between pages.
 
 ==== How to upload files
 
-To upload files you follow the *Add Media File* link in the top right of
-the page. You will see the Media File Add page, which is pictured below.
-
-image::user-guide-13-add-media.png[]
-
-You can upload up to five files at a time and you can enter information
-about the images including title, description, copyright statement and
-tags. You can pick which directory should receive the uploaded images.
+Click *Upload files*. Choose the folder for the files, then choose files with
+the file picker or drag them onto the page. You can upload up to 20 files at
+a time; the page shows this limit and the size limits your site allows. Each
+file is listed with its name and size, and you can remove a file from the
+list before you upload.
 
-You can also decide whether or not you want your images to be included
-in the Gallery, which means that they will be made available in the
-Media File Feed for your blog.
+Under *Apply to these files* you can enter a description, tags and a
+copyright statement for all the files, and choose whether to include them in
+the Gallery, which makes them available in the Media File Feed for your
+blog. Each file keeps its own name; you can rename a file later on its
+details page.
 
-After your file upload completes, Roller will show you the *Upload
-Complete* page (below) with the files that you uploaded and will offer
-to include them in a new weblog post for you. You can choose any or all
-of the images, or you can skip this step and return to the Media File
-View.
+The description of an image is its _alt text_: Roller uses it when you insert
+the image in an entry, for readers who cannot see the image. Describe what the
+image shows.
 
-image::user-guide-14-upload-complete.png[]
+Click *Upload*. Each file in the list shows whether it was uploaded or why it
+failed. If some files fail, *Retry failed files* sends only those files again;
+files that were uploaded are never sent twice. If the connection is lost
+after the files were sent, Roller cannot tell which files were saved. Open
+the folder to check before you upload them again.
 
-==== How to edit and update files
+When the files are uploaded, Roller shows the *Upload Complete* page with the
+files that you uploaded and offers to include them in a new weblog post for
+you. You can choose any or all of the images, or skip this step and return to
+the library.
 
-From the Media File View page, you can edit any Media File simply by
-clicking on it. When you click you will be shown the Media File Edit
-page (below). From this page, you can edit the same information that you
-entered when you uploaded the file.
+==== How to find files
 
-You can also upload a new version of the file. The file will maintain
-the same URL as before the update, so no worries about broken links. If
-the file is an image, a new thumbnail will be generated for you and
-image size information will be updated.
+Above the files, enter the start of a file name and click *Search*. Upper and
+lower case do not matter. You can also limit the search to a file type, and
+choose whether to search the current folder or all folders. *Filters* has
+more criteria: file size and tags. The line above the results shows what you
+searched for and how many files match; *Clear search* returns to the folder.
 
-image::user-guide-15-edit-media.png[]
+==== How to see and edit a file
 
-==== How to use Media File Directories
+Click a file’s preview or name to open its details page. It shows a larger
+preview, the file’s type, size, image dimensions, upload date and folder, and
+its URL. *Copy URL* copies the URL for use elsewhere, *Open original* opens
+the file, *Create entry* starts a new weblog entry with the file, and
+*Delete* deletes it.
 
-You can use directories to organize your Media Files. You can move files
-around and not worry about breaking any links because directory and file
-names are not part of URLs.
+Below that you can edit the name, description, tags, copyright statement,
+folder and Gallery setting, and click *Save*. *Back to the media library*
+returns you to the same folder, search, sort and page that you came from.
 
-To create a new directory, enter a new directory name in the new
-directory control, and click the create button.
+==== How to use folders
 
-image::user-guide-media-directory.png[]
+You can use folders to organize your files. You can move files around and not
+worry about breaking any links because folder and file names are not part of
+file URLs.
 
-To navigate into a directory in the Media File View page, simply click
-on the directory.
+To create a folder, click *New folder* above the folder list, enter a name
+and click *Create*.
 
-==== How to delete Media Files
+To move files, select them with their checkboxes, choose the destination
+folder in the toolbar above the files, and click *Move*. *Select this page*
+selects every file on the current page.
 
-To delete Media Files, go to the *Media File View* page, select the
-checkboxes of the files you wish to delete and then click the Delete
-button. You will have to confirm the delete before it executes.
+==== How to delete files and folders
 
-==== How to delete Media File Directories
+To delete files, select them with their checkboxes and click *Delete* in the
+toolbar above the files, or click *Delete* on a file’s details page. You will
+have to confirm the delete before it executes. Deleting a file cannot be
+undone, and links to it stop working.
 
-To delete Media File Directories you must first empty them out. You can
-only delete directories that are empty.
+To delete a folder, open it and click *Delete folder* below the files. This
+deletes the folder and all the files in it. You cannot delete the default
+folder.
 
 ==== How to post media files to your weblog
 
-We explained above how to post images during the upload process. From
-the Blog entry edit page, click on the "Add Media File" link located
-above and to the right of the Content field. Roller will insert the
-media file at the cursor location in the content field. If there’s a
-problem with the insertion location, hit Ctrl-Z to undo the action and
-try again.
+We explained above how to post images during the upload process. From the
+Blog entry edit page, click on the "Add Media File" link located above and to
+the right of the Content field. Choose a folder, or search for the file by
+name, and click the file. Roller inserts an image as a thumbnail that links to
+the full image, with the image’s description as its alt text, and inserts any
+other file as a link. Roller inserts the media file at the cursor location in
+the content field. If there’s a problem with the insertion location, hit
+Ctrl-Z to undo the action and try again.
 
 ==== How to post a podcast to your weblog
 

Reply via email to