*/
public function deleteFiles()
{
+ if ($this->fileID !== null) {
+ return;
+ }
+
@\unlink($this->getLocation());
if ($this->tinyThumbnailType) {
@\unlink($this->getTinyThumbnailLocation());
namespace wcf\data\file;
use wcf\data\AbstractDatabaseObjectAction;
+use wcf\system\file\processor\FileProcessor;
/**
* @author Alexander Ebert
class FileAction extends AbstractDatabaseObjectAction
{
protected $className = FileEditor::class;
+
+ #[\Override]
+ public function delete()
+ {
+ if ($this->objects === []) {
+ $this->readObjects();
+ }
+
+ if ($this->objects !== []) {
+ FileProcessor::getInstance()->delete($this->objects);
+ }
+
+ return parent::delete();
+ }
}
use CuyZ\Valinor\Mapper\MappingError;
use wcf\data\attachment\Attachment;
+use wcf\data\attachment\AttachmentAction;
use wcf\data\attachment\AttachmentEditor;
use wcf\data\file\File;
use wcf\data\file\thumbnail\FileThumbnail;
]);
}
+ #[\Override]
+ public function delete(array $fileIDs, array $thumbnailIDs): void
+ {
+ (new AttachmentAction($fileIDs, 'delete'))->executeAction();
+ }
+
private function getAttachmentHandlerFromContext(array $context): ?AttachmentHandler
{
try {
use wcf\data\file\thumbnail\FileThumbnail;
use wcf\data\file\thumbnail\FileThumbnailEditor;
use wcf\data\file\thumbnail\FileThumbnailList;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\event\EventHandler;
use wcf\system\file\processor\event\FileProcessorCollecting;
use wcf\system\image\adapter\ImageAdapter;
use wcf\system\image\ImageHandler;
use wcf\system\SingletonFactory;
+use wcf\system\WCF;
use wcf\util\FileUtil;
use wcf\util\JSON;
use wcf\util\StringUtil;
$processor->adoptThumbnail($fileThumbnail);
}
}
+
+ public function delete(array $files): void
+ {
+ $fileIDs = \array_column($files, 'fileID');
+
+ $conditions = new PreparedStatementConditionBuilder();
+ $conditions->add('fileID IN (?)', [$fileIDs]);
+
+ $sql = "SELECT thumbnailID
+ FROM wcf1_file_thumbnail
+ {$conditions}";
+ $statement = WCF::getDB()->prepare($sql);
+ $statement->execute($conditions->getParameters());
+ $thumbnailIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
+
+ foreach ($this->processors as $processor) {
+ $processor->delete($fileIDs, $thumbnailIDs);
+ }
+ }
}
public function canDownload(File $file): bool;
+ /**
+ * @param list<int> $files
+ * @param list<int> $thumbnails
+ */
+ public function delete(array $fileIDs, array $thumbnailIDs): void;
+
public function getAllowedFileExtensions(array $context): array;
public function getResizeConfiguration(): ResizeConfiguration;
$float = 'none';
$thumbnail = false;
-
- if (\strpos($element->getAttribute('src'), 'thumbnail=1') !== false) {
+ $src = $element->getAttribute('src');
+ if (\str_contains($src, 'thumbnail=1') || \str_ends_with($src, '.webp')) {
$thumbnail = true;
}