From: Miguel Dantas Date: Sat, 15 Jun 2019 23:41:54 +0000 (+0100) Subject: [MEDIA][UI] In case an attachment preview isn't possible, the name is displayed anyway X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5961b45140c15cd0067ee3064afac6cd88144c5a;p=quix0rs-gnu-social.git [MEDIA][UI] In case an attachment preview isn't possible, the name is displayed anyway --- diff --git a/js/util.js b/js/util.js index 2e966dfcef..282c89a83d 100644 --- a/js/util.js +++ b/js/util.js @@ -965,11 +965,11 @@ var SN = { // StatusNet preview = false; } + var fileentry = $('
  • ') + .attr('class', 'attachment') + .attr('style', 'text-align: center'); if (preview) { blobAsDataURL(file, function (url) { - var fileentry = $('
  • ') - .attr('class', 'attachment') - .attr('style', 'text-align: center'); var img = $('') .attr('title', tooltip) .attr('alt', tooltip) @@ -980,8 +980,9 @@ var SN = { // StatusNet form.find('.attach-status').append(fileentry); }); } else { - var img = $('
    ').text(tooltip); - form.find('.attach-status').append(img); + fileentry.append($('' + file.type + '')); + fileentry.append($('
    ' + file.name + '')); + form.find('.attach-status').append(fileentry); } }, diff --git a/lib/attachmentlistitem.php b/lib/attachmentlistitem.php index de1087d44c..390c450088 100644 --- a/lib/attachmentlistitem.php +++ b/lib/attachmentlistitem.php @@ -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() { diff --git a/lib/framework.php b/lib/framework.php index 024ee1b1bf..bd7693f5d7 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -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); diff --git a/lib/imagefile.php b/lib/imagefile.php index 6794971fbb..2138a03e60 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -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 diff --git a/lib/mediafile.php b/lib/mediafile.php index 3445f4b8e5..4dc75a71a9 100644 --- a/lib/mediafile.php +++ b/lib/mediafile.php @@ -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