summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8665ea5)
- avoid previewing text/*
- javascript side more clear
closes #264
Signed-off-by: Jerome Jutteau <jerome@jutteau.fr>
// Test if content can be previewed
type = document.getElementById('file_select').files[0].type;
// Test if content can be previewed
type = document.getElementById('file_select').files[0].type;
- if (type.indexOf("image") > -1 ||
- type.indexOf("audio") > -1 ||
- type.indexOf("text") > -1 ||
- type.indexOf("video") > -1)
+ if (type.startsWith('image/') ||
+ type.startsWith('audio') ||
+ type.startsWith('text/plain') ||
+ type.startsWith('video/'))
{
document.getElementById('preview_link').href = preview_link_href;
document.getElementById('preview_link_text').innerHTML = web_root + preview_link_href;
{
document.getElementById('preview_link').href = preview_link_href;
document.getElementById('preview_link_text').innerHTML = web_root + preview_link_href;
function jirafeau_is_viewable($mime)
{
if (!empty($mime)) {
function jirafeau_is_viewable($mime)
{
if (!empty($mime)) {
- /* Actually, verify if mime-type is an image or a text. */
- $viewable = array('image', 'text', 'video', 'audio');
+ $viewable = array('image', 'video', 'audio');
$decomposed = explode('/', $mime);
$decomposed = explode('/', $mime);
- return in_array($decomposed[0], $viewable);
+ if (in_array($decomposed[0], $viewable)) {
+ return true;
+ }
+ $viewable = array('text/plain');
+ if (in_array($mime, $viewable)) {
+ return true;
+ }