Compare commits

..

3 commits

Author SHA1 Message Date
mrilyew
5d3ad59f82
Merge 9a817fe12f into aa2a1636df 2025-01-16 20:31:16 +00:00
mrilyew
9a817fe12f add gif play on click 2025-01-16 23:31:12 +03:00
mrilyew
a5aa09d554 fix low register format chekc 2025-01-16 21:32:56 +03:00
5 changed files with 46 additions and 12 deletions

View file

@ -104,7 +104,7 @@ class Document extends Media
if(!$file_format)
throw new \TypeError("No file format");
if(!in_array($file_format, OPENVK_ROOT_CONF["openvk"]["preferences"]["docs"]["allowedFormats"]))
if(!in_array(mb_strtolower($file_format), OPENVK_ROOT_CONF["openvk"]["preferences"]["docs"]["allowedFormats"]))
throw new \TypeError("Forbidden file format");
if($file_size < 1 || $file_size > (OPENVK_ROOT_CONF["openvk"]["preferences"]["docs"]["maxSize"] * 1024 * 1024))
@ -112,8 +112,8 @@ class Document extends Media
$hash = hash_file("whirlpool", $file["tmp_name"]);
$this->stateChanges("original_name", ovk_proc_strtr($original_name, 255));
$this->tmp_format = $file_format;
$this->stateChanges("format", $file_format);
$this->tmp_format = mb_strtolower($file_format);
$this->stateChanges("format", mb_strtolower($file_format));
$this->stateChanges("filesize", $file_size);
$this->stateChanges("hash", $hash);
$this->stateChanges("access_key", bin2hex(random_bytes(9)));
@ -166,6 +166,11 @@ class Document extends Media
return in_array($this->getVKAPIType(), [3, 4]);
}
function isGif(): bool
{
return $this->getVKAPIType() == 3;
}
function isCopiedBy($user = NULL): bool
{
if(!$user)
@ -386,7 +391,7 @@ class Document extends Media
static function detectTypeByFormat(string $format)
{
switch($format) {
switch(mb_strtolower($format)) {
case "txt": case "docx": case "doc": case "odt": case "pptx": case "ppt": case "xlsx": case "xls": case "md":
return 1;
case "zip": case "rar": case "7z":

View file

@ -2,8 +2,14 @@
{var $copied = !isset($club) ? $doc->isCopiedBy($thisUser) : $doc->isCopiedBy($club)}
{var $modifiable = $doc->canBeModifiedBy($thisUser)}
<a href="/doc{$doc->getPrettyId()}?key={$doc->getAccessKey()}" n:class="docMainItem, viewerOpener, docGalleryItem, $scroll_context ? scroll_node" data-id="{$doc->getPrettiestId()}">
<img loading="lazy" src="{$preview->getURLBySizeId('medium')}" alt="gallery photo">
<a href="/doc{$doc->getPrettyId()}?key={$doc->getAccessKey()}" n:class="docMainItem, viewerOpener, docGalleryItem, $scroll_context ? scroll_node, $embed ? embeddable" data-id="{$doc->getPrettiestId()}">
<img class="docGalleryItem_main_preview" loading="lazy" src="{$preview->getURLBySizeId('medium')}" alt="gallery photo">
{if $embed}
<div class="play-button">
<div class="play-button-ico"></div>
</div>
<img class="docGalleryItem_gif_preview" loading="lazy" src="{$doc->getURL()}" alt="gif photo view">
{/if}
<div class="doc_top_panel doc_shown_by_hover">
<div class="doc_volume_action" n:if="!$modifiable" id="report_icon"></div>

View file

@ -78,7 +78,7 @@
</div>
</div>
{if $attachment->isImage()}
{include "../Documents/components/image.xml", doc => $attachment, copyImportance => true, showInfo => true}
{include "../Documents/components/image.xml", doc => $attachment, copyImportance => true, showInfo => true, embed => $attachment->isGif()}
{else}
{include "../Documents/components/doc.xml", doc => $attachment, copyImportance => true, noTags => true}
{/if}

View file

@ -2574,7 +2574,7 @@ a.poll-retract-vote {
min-height: 63px;
}
.post-horizontal .upload-item .play-button, .compact_video .play-button {
.post-horizontal .upload-item .play-button, .compact_video .play-button, .docGalleryItem .play-button {
position: absolute;
height: 30px;
width: 30px;
@ -2585,7 +2585,7 @@ a.poll-retract-vote {
align-items: center;
}
.post-horizontal .upload-item .play-button .play-button-ico, .compact_video .play-button .play-button-ico {
.post-horizontal .upload-item .play-button .play-button-ico, .compact_video .play-button .play-button-ico, .docGalleryItem .play-button .play-button-ico {
background: url(/assets/packages/static/openvk/img/wall.png) no-repeat 1px 0;
display: inline-block;
height: 15px;
@ -4035,6 +4035,25 @@ hr {
/*width: 200px;*/
}
.attachments .docGalleryItem.embeddable {
display: flex;
align-items: center;
justify-content: center;
/*background: black;*/
}
.attachments .docGalleryItem.embeddable .docGalleryItem_gif_preview {
object-fit: contain;
}
.attachments .docGalleryItem.embeddable.playing .play-button, .attachments .docGalleryItem.embeddable.playing .doc_bottom_panel, .docGalleryItem .docGalleryItem_gif_preview, .attachments .docGalleryItem.embeddable.playing .docGalleryItem_main_preview {
display: none;
}
.attachments .docGalleryItem.embeddable.playing .docGalleryItem_gif_preview {
display: block;
}
.docGalleryItem img {
width: 100%;
height: 100%;
@ -4220,8 +4239,8 @@ hr {
.attachments .docGalleryItem {
display: block;
min-width: 130px;
height: 150px;
min-width: 170px;
height: 170px;
width: 50%;
margin-bottom: 4px;
}

View file

@ -27,7 +27,7 @@ function showDocumentUploadDialog(target = null, append_to_url = null, after_upl
file = e.target.files[0]
const name = file.name
const format = name.split(".")[name.split(".").length - 1]
if(window.openvk.docs_allowed.indexOf(format) == -1) {
if(window.openvk.docs_allowed.indexOf(format.toLowerCase()) == -1) {
makeError(tr("error_file_invalid_format"))
return
}
@ -269,6 +269,10 @@ u(document).on("click", ".docListViewItem a.viewerOpener, a.docGalleryItem", asy
const target = u(e.target)
const link = target.closest('a')
if(target.closest(".embeddable").length > 0) {
target.closest(".embeddable").toggleClass("playing")
return
}
CMessageBox.toggleLoader()
const url = link.nodes[0].href