The filename should remain intact with hyphens when uploading through drag and drop.
Image files uploaded through drag and drop gets stripped of it's hyphens.
Joomla 3.9.1. Editor is TinyMCE. Content and backend language is Swedish.
Missing hyphens in file names is harmful to SEO as Google reads hyphens as spaces. I.e. a file named a-nice-glass-of-beer.jpg is read by Google as "a nice glass of beer.jpg" and can be interpreted correctly. When the hyphens are missing Google will have a hard time understanding what aniceglassofbeer.jpg is.
@infograf768 has nothing to do with tinyMCE or the drag and drop script, it's coming from this line: https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_media/controllers/file.json.php#L88
@dgrammatiko
Weird. Why would we replace hyphens by nothing in that json file and not when we upload through "normal" com_media upload?
Even better, we replace spaces by hyphens in "normal" upload...
In any case, changing that code to
$safeFileName = preg_replace(array("/[\\s]/", '/[^a-zA-Z0-9_\-]/'), array('_', ''), $fileparts['filename']) . '.' . $tempExt;
looks like solving the specific issue.
@dgrammatiko
It looks you are the one who did not add the hyphen in this preg_replace
see https://github.com/joomla/joomla-cms/pull/7435/files#diff-e5953bc3eadad37980d677840c9d4f6dR88
years ago . ROTFLOL
May I make patch?
@infograf768: I can verify that the suggested code change resolves the issue.
It does, but remains to modify some stuff in the "normal" upload.
I explain:
the name of a file should not contain any period .
before the extension.
(real original name of these files are of the type: Screen Shot 2018-12-09 at 07.43.58.png
on my Mac)
This is nicely taken care of when drag and drop as periods are replaced by nothing (after adding the hyphen in the code above).
Screen_Shot_2018-12-09_at_075108.png
BUT not in normal upload where I get:
Screen-Shot-2018-12-10-at-09.29.49.png
Also, spaces are replaced by hyphens in one case and by underscores in the other.
I think this should be normalized.
Will try to solve these issues, making sure that the files can also be deleted by com_media.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-12-10 19:09:18 |
Closed_By | ⇒ | Quy |
Closed_By | Quy | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/23249
I am afraid this does not depend on Joomla but on TinyMCE itself.
@dgrammatiko ?