Skip to content

Commit

Permalink
Merge pull request #56 from VairisO/master
Browse files Browse the repository at this point in the history
- bugfix
  • Loading branch information
VairisO authored Mar 17, 2021
2 parents 0bb5199 + eba807a commit 2e83c3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion assets/js/d3files-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
}
}
if ("png" === ext || "jpg" === ext || "jpeg" === ext || "gif" === ext) {
this.loadImage(f, this.handlers.modalContent);
this.loadImage(f);
this.activeFile = f;
return true;
}
Expand All @@ -215,10 +215,13 @@
D3PDF.trigger (f.src);
},
loadImage: function (f) {
$('.th-modal-content').empty();
$('.modal-dialog .modal-content').css('height', 'unset');
new PhotoViewer([{
src: f.src
}]);
this.handlers.imageContent.show();

},
getModelIndex: function (modelId) {
let index = null;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/d3photo-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@
// Load the image progressively
progressiveLoading: true,
// The DOM element to which viewer will be added
insertInto: 'div.th-modal-content', // div.th-modal-content
insertInto: 'div.d3preview-image-content', // div.th-modal-content
// Custom Buttons
customButtons: {}
};
Expand Down
14 changes: 9 additions & 5 deletions widgets/D3FilesPreviewWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class D3FilesPreviewWidget extends D3FilesWidget

public $icon = self::DEFAULT_ICON;
public $previewExtensions = '/(gif|pdf|jpe?g|png)$/i';
public $viewExtension = 'pdf';
public $viewExtension = ['pdf', 'jpg'];
public $currentFile;
public $showPrevNext = false;
public $prevFile;
Expand Down Expand Up @@ -242,9 +242,9 @@ public function getModalToolbarContent(): string
<span class="d3preview-model-files pull-left"></span>
</div>
<div class="col-sm-5 text-center">' . $previewButtons . '</div>
<div class="col-sm-3 text-center">
<div class="d3preview-image-content" style="display: none"></div>
</div>
</div>
<div class="row">
<div class="d3preview-image-content" style="display: none"></div>
</div>
';
}
Expand Down Expand Up @@ -279,7 +279,11 @@ public function getViewParams(): ?array
];

if (self::VIEW_MODAL_BUTTON === $this->view || self::VIEW_INLINE_BUTTON === $this->view) {
$params['file'] = D3Files::getFirstFileHavingExt($this->fileList, $this->viewExtension);
foreach ($this->viewExtension as $key => $extension) {
if($params['file'] = D3Files::getFirstFileHavingExt($this->fileList, $extension)) {
break;
}
}
}

$params = array_merge(
Expand Down

0 comments on commit 2e83c3c

Please sign in to comment.