]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
[MEDIA][UI] In case an attachment preview isn't possible, the name is displayed anyway
authorMiguel Dantas <biodantasgs@gmail.com>
Sat, 15 Jun 2019 23:41:54 +0000 (00:41 +0100)
committerDiogo Cordeiro <diogo@fc.up.pt>
Sat, 3 Aug 2019 16:31:39 +0000 (17:31 +0100)
js/util.js
lib/attachmentlistitem.php
lib/framework.php
lib/imagefile.php
lib/mediafile.php

index 2e966dfcef87fad30a1701c0a2f6cd680fb71b15..282c89a83d6535773ba20fbfc518f9837b2c9004 100644 (file)
@@ -965,11 +965,11 @@ var SN = { // StatusNet
                 preview = false;
             }
 
+            var fileentry = $('<li>')
+                .attr('class', 'attachment')
+                .attr('style', 'text-align: center');
             if (preview) {
                 blobAsDataURL(file, function (url) {
-                    var fileentry = $('<li>')
-                        .attr('class', 'attachment')
-                        .attr('style', 'text-align: center');
                     var img = $('<img>')
                         .attr('title', tooltip)
                         .attr('alt', tooltip)
@@ -980,8 +980,9 @@ var SN = { // StatusNet
                     form.find('.attach-status').append(fileentry);
                 });
             } else {
-                var img = $('<div></div>').text(tooltip);
-                form.find('.attach-status').append(img);
+                fileentry.append($('<code>' + file.type + '</code>'));
+                fileentry.append($('<br><code>' + file.name + '</code>'));
+                form.find('.attach-status').append(fileentry);
             }
         },
 
index de1087d44cb75f360df589ecd4abfe8ed9566207..390c450088211125f3a8fd1fcc4d33d5c50d93e2 100644 (file)
@@ -63,7 +63,7 @@ class AttachmentListItem extends Widget
     }
 
     function title() {
-        return $this->attachment->getTitle() ?: _('Untitled attachment');
+        return $this->attachment->getTitle() ?: MediaFile::getDisplayName($this->attachment);
     }
 
     function linkTitle() {
index 024ee1b1bf907a66dcdbccc344ae4f2faa118ee5..bd7693f5d7f4331178b8633a6e1456c4f17de8cd 100644 (file)
@@ -32,7 +32,7 @@ defined('GNUSOCIAL') || die();
 define('GNUSOCIAL_ENGINE', 'GNU social');
 define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/');
 
-define('GNUSOCIAL_BASE_VERSION', '1.21.1');
+define('GNUSOCIAL_BASE_VERSION', '1.21.2');
 define('GNUSOCIAL_LIFECYCLE', 'dev'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
 
 define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);
index 6794971fbb5c91e86a99647557d62bada03a80f5..2138a03e60f8c1721309c1f5c3a30eae489c2ab5 100644 (file)
@@ -611,9 +611,9 @@ class ImageFile extends MediaFile
 
         return File_thumbnail::saveThumbnail(
             $this->fileRecord->getID(),
-                                             // no url since we generated it ourselves and can dynamically
-                                             // generate the url
-                                             null,
+            // no url since we generated it ourselves and can dynamically
+            // generate the url
+            null,
             $width,
             $height,
             $outname
index 3445f4b8e58e297b6dfdef03fd2990244f2ec55c..4dc75a71a9ca047c5d70fef41733714147fe33ba 100644 (file)
@@ -380,8 +380,7 @@ class MediaFile
             $mimetype = self::getUploadedMimeType($_FILES[$param]['tmp_name'], $_FILES[$param]['name']);
             $media = common_get_mime_media($mimetype);
 
-            $basename = preg_replace("/\..+$/i", '', basename($_FILES[$param]['name']));
-            $ext = File::guessMimeExtension($mimetype, $basename);
+            $basename = basename($_FILES[$param]['name']);
 
             if ($media === 'image') {
                 // Use -1 for the id to avoid adding this temporary file to the DB
@@ -392,6 +391,11 @@ class MediaFile
                 $ext = image_type_to_extension($img->preferredType(), false);
             }
 
+            // If we have a replacement extension (either from the config or from converting an image)
+            if ($ext !== false) {
+                $basename = preg_replace("/\..+$/i", ".{$ext}", $basename);
+            }
+
             // New file name format
             $original_filename = bin2hex("{$basename}.{$ext}");
             $filename = "{$original_filename}-{$filehash}";
@@ -649,7 +653,7 @@ class MediaFile
             $ret = preg_match('/^[^\.]+\.(.+)$/', $file->filename, $matches);
             if ($ret !== 1) {
                 common_log(LOG_ERR, $log_error_msg);
-                throw new ServerException($user_error_msg);
+                return _('Untitled attachment');
             }
             $ext = $matches[1];
             // Previously, there was a blacklisted extension array, which could have an alternative