[MEDIA][UI] In case an attachment preview isn't possible, the name is displayed anyway

This commit is contained in:
Miguel Dantas 2019-06-16 00:41:54 +01:00 committed by Diogo Cordeiro
parent 5f53738376
commit 5961b45140
5 changed files with 18 additions and 13 deletions

View 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);
}
},

View 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() {

View 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);

View 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

View 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