summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2017-11-25 21:27:14 +0000
committerGreg Roach <fisharebest@gmail.com>2017-11-25 21:27:14 +0000
commit7f6d5696ae2bdcc40efc4da56265761fa7485eb6 (patch)
treecf52f8cae58b420b926c0ce06dd14afbc900ab6c
parent3652be65cd8716e23fbdcd26714694cc71088c60 (diff)
downloadwebtrees-7f6d5696ae2bdcc40efc4da56265761fa7485eb6.tar.gz
webtrees-7f6d5696ae2bdcc40efc4da56265761fa7485eb6.tar.bz2
webtrees-7f6d5696ae2bdcc40efc4da56265761fa7485eb6.zip
Remove old thumbnail code
-rw-r--r--admin_media_upload.php35
-rw-r--r--app/Functions/FunctionsPrintFacts.php4
-rw-r--r--app/Report/ReportParserGenerate.php4
-rw-r--r--edit_interface.php37
4 files changed, 9 insertions, 71 deletions
diff --git a/admin_media_upload.php b/admin_media_upload.php
index 033f41d448..f66d31662a 100644
--- a/admin_media_upload.php
+++ b/admin_media_upload.php
@@ -35,7 +35,7 @@ $action = Filter::post('action');
if ($action == 'upload') {
for ($i = 1; $i < 6; $i++) {
- if (!empty($_FILES['mediafile' . $i]['name']) || !empty($_FILES['thumbnail' . $i]['name'])) {
+ if (!empty($_FILES['mediafile' . $i]['name'])) {
$folder = Filter::post('folder' . $i);
// Validate the media folder
@@ -86,19 +86,6 @@ if ($action == 'upload') {
}
}
- // A thumbnail file with no main image?
- if (!empty($_FILES['thumbnail' . $i]['name']) && empty($_FILES['mediafile' . $i]['name'])) {
- // Assume the user used the wrong field, and treat this as a main image
- $_FILES['mediafile' . $i] = $_FILES['thumbnail' . $i];
- unset($_FILES['thumbnail' . $i]);
- }
-
- // Thumbnail files must contain images.
- if (!empty($_FILES['thumbnail' . $i]['name']) && !preg_match('/^image\/(png|gif|jpeg)/', $_FILES['thumbnail' . $i]['type'])) {
- FlashMessages::addMessage(I18N::translate('Thumbnail files must contain images.'));
- break;
- }
-
// User-specified filename?
$filename = Filter::post('filename' . $i);
// Use the name of the uploaded file?
@@ -144,17 +131,6 @@ if ($action == 'upload') {
$filename = '';
break;
}
-
- // Now copy the (optional thumbnail)
- if (!empty($_FILES['thumbnail' . $i]['name']) && preg_match('/^image\/(png|gif|jpeg)/', $_FILES['thumbnail' . $i]['type'], $match)) {
- $extension = $match[1];
- $thumbFile = preg_replace('/\.[a-z0-9]{3,5}$/', '.' . $extension, $fileName);
- $serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName . $thumbFile;
- if (move_uploaded_file($_FILES['thumbnail' . $i]['tmp_name'], $serverFileName)) {
- FlashMessages::addMessage(I18N::translate('The file %s has been uploaded.', Html::filename($serverFileName)));
- Log::addMediaLog('Thumbnail file ' . $serverFileName . ' uploaded');
- }
- }
}
}
}
@@ -198,15 +174,6 @@ for ($i = 1; $i < 6; $i++) {
echo '<td>';
echo '<input name="mediafile', $i, '" type="file" size="40">';
echo '</td></tr>';
- echo '<tr><td>';
- echo I18N::translate('Thumbnail to upload');
- echo '</td>';
- echo '<td>';
- echo '<input name="thumbnail', $i, '" type="file" size="40">';
- if ($i === 1) {
- echo '<p class="small text-muted">', I18N::translate('Choose the thumbnail image that you want to upload. Although thumbnails can be generated automatically for images, you may wish to generate your own thumbnail, especially for other media types. For example, you can provide a still image from a video, or a photograph of the individual who made an audio recording.'), '</p>';
- }
- echo '</td></tr>';
if (Auth::isManager($WT_TREE)) {
echo '<tr><td>';
diff --git a/app/Functions/FunctionsPrintFacts.php b/app/Functions/FunctionsPrintFacts.php
index d50d233626..c3fdd2bb89 100644
--- a/app/Functions/FunctionsPrintFacts.php
+++ b/app/Functions/FunctionsPrintFacts.php
@@ -242,12 +242,12 @@ class FunctionsPrintFacts {
if (Auth::isEditor($fact->getParent()->getTree())) {
echo '<div class="field">', Html::escape($fact->getValue());
- if ($fact->getParent() instanceof Media && $fact->getParent()->fileExists('main') && $fact->getParent()->getTree()->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($fact->getParent()->getTree())) {
+ if ($fact->getParent() instanceof Media && $fact->getParent()->fileExists() && $fact->getParent()->getTree()->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($fact->getParent()->getTree())) {
echo ' — <a href="' . $fact->getParent()->imageUrl(0, 0, '') . '">' . I18N::translate('Download file') . '</a>';
}
echo '</div>';
- if ($fact->getParent() instanceof Media && !$fact->getParent()->fileExists('main')) {
+ if ($fact->getParent() instanceof Media && !$fact->getParent()->fileExists()) {
echo '<p class="alert alert-danger">' . I18N::translate('The file ā€œ%sā€ does not exist.', $fact->getParent()->getFilename()) . '</p>';
}
diff --git a/app/Report/ReportParserGenerate.php b/app/Report/ReportParserGenerate.php
index ba97e8e06a..bd9073ebc5 100644
--- a/app/Report/ReportParserGenerate.php
+++ b/app/Report/ReportParserGenerate.php
@@ -1635,7 +1635,7 @@ class ReportParserGenerate extends ReportParserBase {
'WBMP',
'XBM',
]
- ) && $mediaobject->canShow() && $mediaobject->fileExists('main')
+ ) && $mediaobject->canShow() && $mediaobject->fileExists()
) {
if ($width > 0 && $height == 0) {
$perc = $width / $attributes[0];
@@ -1736,7 +1736,7 @@ class ReportParserGenerate extends ReportParserBase {
'WBMP',
'XBM',
]
- ) && $mediaobject->canShow() && $mediaobject->fileExists('main')
+ ) && $mediaobject->canShow() && $mediaobject->fileExists()
) {
if ($width > 0 && $height == 0) {
$perc = $width / $attributes[0];
diff --git a/edit_interface.php b/edit_interface.php
index d74f70fa89..e364acaaba 100644
--- a/edit_interface.php
+++ b/edit_interface.php
@@ -23,7 +23,8 @@ use Fisharebest\Webtrees\Functions\FunctionsDb;
use Fisharebest\Webtrees\Functions\FunctionsEdit;
use Fisharebest\Webtrees\Functions\FunctionsImport;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
-use Fisharebest\Webtrees\GedcomCode\GedcomCodeName;use Fisharebest\Webtrees\GedcomCode\GedcomCodePedi;
+use Fisharebest\Webtrees\GedcomCode\GedcomCodeName;
+use Fisharebest\Webtrees\GedcomCode\GedcomCodePedi;
use Fisharebest\Webtrees\Module\CensusAssistantModule;
require 'includes/session.php';
@@ -608,15 +609,6 @@ case 'media-edit':
</div>
<div class="form-group row">
- <label class="col-form-label col-sm-3" for="thumbnail">
- <?= I18N::translate('Thumbnail to upload') ?>
- </label>
- <div class="col-sm-9">
- <input type="file" class="form-control" id="thumbnail" name="thumbnail">
- </div>
- </div>
-
- <div class="form-group row">
<label class="col-sm-3 col-form-label" for="TITL">
<?= I18N::translate('Title') ?>
</label>
@@ -739,22 +731,10 @@ case 'media-save':
}
}
- // Replacement files?
- if (!empty($_FILES['thumbnail']) && is_uploaded_file($_FILES['thumbnail']['tmp_name'])) {
- if (!move_uploaded_file($_FILES['thumbnail']['tmp_name'], $old_server_thumb)) {
- FlashMessages::addMessage(
- I18N::translate('There was an error uploading your file.') .
- '<br>' .
- Functions::fileUploadErrorText($_FILES['thumbnail']['error'])
- );
- }
- }
-
$tmp_record = new Media('xxx', "0 @xxx@ OBJE\n1 FILE " . $FILE, null, $record->getTree());
- $new_server_file = $tmp_record->getServerFilename('main');
- $new_server_thumb = $tmp_record->getServerFilename('thumb');
- $new_external = $tmp_record->isExternal();
+ $new_server_file = $tmp_record->getServerFilename('main');
+ $new_external = $tmp_record->isExternal();
// External URLs cannot be renamed to local files, and vice versa.
if ($old_external !== $new_external) {
@@ -809,15 +789,6 @@ case 'media-save':
if (!file_exists($new_server_file)) {
FlashMessages::addMessage(I18N::translate('The media file %s does not exist.', Html::filename($FILE)), 'warning');
}
-
- if (!file_exists($new_server_thumb) || sha1_file($old_server_thumb) === sha1_file($new_server_thumb)) {
- try {
- rename($old_server_thumb, $new_server_thumb);
- } catch (ErrorException $ex) {
- DebugBar::addThrowable($ex);
-
- }
- }
}
$record->updateFact($fact_id, $gedcom, !$keep_chan);