Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
e93f98f1
Commit
e93f98f1
authored
10 years ago
by
Lukas Reschke
Browse files
Options
Downloads
Plain Diff
Merge pull request #11368 from owncloud/use-svg-previews
Use SVG previews for public sharing
parents
cbecd622
306bf71c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/files_sharing/js/public.js
+20
-11
20 additions, 11 deletions
apps/files_sharing/js/public.js
apps/files_sharing/templates/public.php
+11
-12
11 additions, 12 deletions
apps/files_sharing/templates/public.php
with
31 additions
and
23 deletions
apps/files_sharing/js/public.js
+
20
−
11
View file @
e93f98f1
...
@@ -56,6 +56,11 @@ OCA.Sharing.PublicApp = {
...
@@ -56,6 +56,11 @@ OCA.Sharing.PublicApp = {
}
}
var
mimetype
=
$
(
'
#mimetype
'
).
val
();
var
mimetype
=
$
(
'
#mimetype
'
).
val
();
var
mimetypeIcon
=
$
(
'
#mimetypeIcon
'
).
val
();
mimetypeIcon
=
mimetypeIcon
.
substring
(
0
,
mimetypeIcon
.
length
-
3
);
mimetypeIcon
=
mimetypeIcon
+
'
svg
'
;
var
previewSupported
=
$
(
'
#previewSupported
'
).
val
();
if
(
typeof
FileActions
!==
'
undefined
'
)
{
if
(
typeof
FileActions
!==
'
undefined
'
)
{
// Show file preview if previewer is available, images are already handled by the template
// Show file preview if previewer is available, images are already handled by the template
...
@@ -68,9 +73,8 @@ OCA.Sharing.PublicApp = {
...
@@ -68,9 +73,8 @@ OCA.Sharing.PublicApp = {
}
}
}
}
// dynamically load image previews
if
(
mimetype
.
substr
(
0
,
mimetype
.
indexOf
(
'
/
'
))
===
'
image
'
)
{
// dynamically load image previews
var
params
=
{
var
params
=
{
x
:
$
(
document
).
width
()
*
window
.
devicePixelRatio
,
x
:
$
(
document
).
width
()
*
window
.
devicePixelRatio
,
y
:
$
(
document
).
height
()
*
window
.
devicePixelRatio
,
y
:
$
(
document
).
height
()
*
window
.
devicePixelRatio
,
...
@@ -81,8 +85,13 @@ OCA.Sharing.PublicApp = {
...
@@ -81,8 +85,13 @@ OCA.Sharing.PublicApp = {
};
};
var
img
=
$
(
'
<img class="publicpreview">
'
);
var
img
=
$
(
'
<img class="publicpreview">
'
);
if
(
previewSupported
===
'
true
'
||
mimetype
.
substr
(
0
,
mimetype
.
indexOf
(
'
/
'
))
===
'
image
'
)
{
img
.
attr
(
'
src
'
,
OC
.
filePath
(
'
files_sharing
'
,
'
ajax
'
,
'
publicpreview.php
'
)
+
'
?
'
+
OC
.
buildQueryString
(
params
));
img
.
attr
(
'
src
'
,
OC
.
filePath
(
'
files_sharing
'
,
'
ajax
'
,
'
publicpreview.php
'
)
+
'
?
'
+
OC
.
buildQueryString
(
params
));
img
.
appendTo
(
'
#imgframe
'
);
img
.
appendTo
(
'
#imgframe
'
);
}
else
if
(
mimetype
.
substr
(
0
,
mimetype
.
indexOf
(
'
/
'
))
!==
'
video
'
)
{
img
.
attr
(
'
src
'
,
OC
.
Util
.
replaceSVGIcon
(
mimetypeIcon
));
img
.
attr
(
'
width
'
,
128
);
img
.
appendTo
(
'
#imgframe
'
);
}
}
if
(
this
.
fileList
)
{
if
(
this
.
fileList
)
{
...
...
This diff is collapsed.
Click to expand it.
apps/files_sharing/templates/public.php
+
11
−
12
View file @
e93f98f1
<?php
/** @var $l OC_L10N */
?>
<?php
/** @var $l OC_L10N */
?>
<?php
$thumbSize
=
1024
;
?>
<?php
$thumbSize
=
1024
;
$previewSupported
=
OC\Preview
::
isMimeSupported
(
$_
[
'mimetype'
])
?
'true'
:
'false'
;
?>
<?php
if
(
\OC\Preview
::
isMimeSupported
(
$_
[
'mimetype'
]))
:
/* This enables preview images for links (e.g. on Facebook, Google+, ...)*/
?>
<?php
if
(
\OC\Preview
::
isMimeSupported
(
$_
[
'mimetype'
]))
:
/* This enables preview images for links (e.g. on Facebook, Google+, ...)*/
?>
<link
rel=
"image_src"
href=
"
<?php
p
(
OCP\Util
::
linkToRoute
(
'core_ajax_public_preview'
,
array
(
'x'
=>
$thumbSize
,
'y'
=>
$thumbSize
,
'file'
=>
$_
[
'directory_path'
],
't'
=>
$_
[
'dirToken'
])));
?>
"
/>
<link
rel=
"image_src"
href=
"
<?php
p
(
OCP\Util
::
linkToRoute
(
'core_ajax_public_preview'
,
array
(
'x'
=>
$thumbSize
,
'y'
=>
$thumbSize
,
'file'
=>
$_
[
'directory_path'
],
't'
=>
$_
[
'dirToken'
])));
?>
"
/>
<?php
endif
;
?>
<?php
endif
;
?>
...
@@ -15,6 +18,10 @@
...
@@ -15,6 +18,10 @@
<input
type=
"hidden"
name=
"sharingToken"
value=
"
<?php
p
(
$_
[
'sharingToken'
])
?>
"
id=
"sharingToken"
>
<input
type=
"hidden"
name=
"sharingToken"
value=
"
<?php
p
(
$_
[
'sharingToken'
])
?>
"
id=
"sharingToken"
>
<input
type=
"hidden"
name=
"filename"
value=
"
<?php
p
(
$_
[
'filename'
])
?>
"
id=
"filename"
>
<input
type=
"hidden"
name=
"filename"
value=
"
<?php
p
(
$_
[
'filename'
])
?>
"
id=
"filename"
>
<input
type=
"hidden"
name=
"mimetype"
value=
"
<?php
p
(
$_
[
'mimetype'
])
?>
"
id=
"mimetype"
>
<input
type=
"hidden"
name=
"mimetype"
value=
"
<?php
p
(
$_
[
'mimetype'
])
?>
"
id=
"mimetype"
>
<input
type=
"hidden"
name=
"previewSupported"
value=
"
<?php
p
(
$previewSupported
);
?>
"
id=
"previewSupported"
>
<input
type=
"hidden"
name=
"mimetypeIcon"
value=
"
<?php
p
(
OC_Helper
::
mimetypeIcon
(
$_
[
'mimetype'
]));
?>
"
id=
"mimetypeIcon"
>
<header><div
id=
"header"
class=
"
<?php
p
((
isset
(
$_
[
'folder'
])
?
'share-folder'
:
'share-file'
))
?>
"
>
<header><div
id=
"header"
class=
"
<?php
p
((
isset
(
$_
[
'folder'
])
?
'share-folder'
:
'share-file'
))
?>
"
>
<a
href=
"
<?php
print_unescaped
(
link_to
(
''
,
'index.php'
));
?>
"
<a
href=
"
<?php
print_unescaped
(
link_to
(
''
,
'index.php'
));
?>
"
title=
""
id=
"owncloud"
>
title=
""
id=
"owncloud"
>
...
@@ -47,23 +54,15 @@
...
@@ -47,23 +54,15 @@
<?php
if
(
isset
(
$_
[
'folder'
]))
:
?>
<?php
if
(
isset
(
$_
[
'folder'
]))
:
?>
<?php
print_unescaped
(
$_
[
'folder'
]);
?>
<?php
print_unescaped
(
$_
[
'folder'
]);
?>
<?php
else
:
?>
<?php
else
:
?>
<?php
if
(
substr
(
$_
[
'mimetype'
],
0
,
strpos
(
$_
[
'mimetype'
],
'/'
))
==
'image'
)
:
?>
<?php
if
(
substr
(
$_
[
'mimetype'
],
0
,
strpos
(
$_
[
'mimetype'
],
'/'
))
==
'video'
)
:
?>
<div
id=
"imgframe"
>
</div>
<?php
elseif
(
substr
(
$_
[
'mimetype'
],
0
,
strpos
(
$_
[
'mimetype'
],
'/'
))
==
'video'
)
:
?>
<div
id=
"imgframe"
>
<div
id=
"imgframe"
>
<video
tabindex=
"0"
controls=
""
preload=
"none"
>
<video
tabindex=
"0"
controls=
""
preload=
"none"
>
<source
src=
"
<?php
p
(
$_
[
'downloadURL'
]);
?>
"
type=
"
<?php
p
(
$_
[
'mimetype'
]);
?>
"
/>
<source
src=
"
<?php
p
(
$_
[
'downloadURL'
]);
?>
"
type=
"
<?php
p
(
$_
[
'mimetype'
]);
?>
"
/>
</video>
</video>
</div>
</div>
<?php
else
:
?>
<?php
else
:
?>
<div
id=
"imgframe"
>
<!-- Preview frame is filled via JS to support SVG images for modern browsers -->
<?php
$size
=
\OC\Preview
::
isMimeSupported
(
$_
[
'mimetype'
])
?
500
:
128
?>
<div
id=
"imgframe"
></div>
<img
src=
"
<?php
p
(
OCP\Util
::
linkToRoute
(
'core_ajax_public_preview'
,
array
(
'x'
=>
$size
,
'y'
=>
$size
,
'file'
=>
$_
[
'directory_path'
],
't'
=>
$_
[
'dirToken'
])));
?>
"
class=
"publicpreview"
alt=
""
/>
</div>
<?php
endif
;
?>
<?php
endif
;
?>
<div
class=
"directDownload"
>
<div
class=
"directDownload"
>
<a
href=
"
<?php
p
(
$_
[
'downloadURL'
]);
?>
"
id=
"download"
class=
"button"
>
<a
href=
"
<?php
p
(
$_
[
'downloadURL'
]);
?>
"
id=
"download"
class=
"button"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment