diff --git a/pom.xml b/pom.xml index e921743..c7200da 100644 --- a/pom.xml +++ b/pom.xml @@ -101,6 +101,12 @@ bootstrap-icons 1.4.1 + + + net.coobird + thumbnailator + 0.4.14 + diff --git a/src/main/kotlin/uk/co/neviyn/booru/Controller.kt b/src/main/kotlin/uk/co/neviyn/booru/Controller.kt index 9fa4554..c353bb4 100644 --- a/src/main/kotlin/uk/co/neviyn/booru/Controller.kt +++ b/src/main/kotlin/uk/co/neviyn/booru/Controller.kt @@ -136,7 +136,7 @@ class UploadController if (!imageConfigurationProperties.types.contains(extension)) return "upload" // TODO: Show error on page, unrecognised file type val user = memberRepository.findByName(userDetails.username)!! val hash: String = generateFileHash(file) - val tagData = tags.split(" ").map { tagRepository.findByTagIs(it) ?: tagRepository.save(Tag(it)) }.toMutableSet() + val tagData = tags.split(" ").map { tagRepository.findByTagIs(it) ?: tagRepository.save(Tag(tag = it)) }.toMutableSet() storage.addImageFile(hash, extension, file.bytes) imageRepository.save(Image("$hash.$extension", user, tagData)) return "upload" // TODO: Show success on page diff --git a/src/main/kotlin/uk/co/neviyn/booru/FileSystemStorage.kt b/src/main/kotlin/uk/co/neviyn/booru/FileSystemStorage.kt index f937ccd..b8c0b4b 100644 --- a/src/main/kotlin/uk/co/neviyn/booru/FileSystemStorage.kt +++ b/src/main/kotlin/uk/co/neviyn/booru/FileSystemStorage.kt @@ -1,5 +1,7 @@ package uk.co.neviyn.booru +import net.coobird.thumbnailator.Thumbnails +import net.coobird.thumbnailator.name.Rename import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service import java.io.File @@ -22,6 +24,7 @@ class FileSystemStorageService override fun addImageFile(name: String, extension: String, data: ByteArray) { val outputFile = File(imageConfigurationProperties.directory, "$name.$extension") outputFile.writeBytes(data) + Thumbnails.of(outputFile).size(200, 200).toFiles(Rename.PREFIX_DOT_THUMBNAIL) } } \ No newline at end of file diff --git a/src/main/resources/templates/gallery.html b/src/main/resources/templates/gallery.html index eeb698e..b7f7e8e 100644 --- a/src/main/resources/templates/gallery.html +++ b/src/main/resources/templates/gallery.html @@ -25,7 +25,7 @@
- +
diff --git a/src/main/resources/templates/upload.html b/src/main/resources/templates/upload.html index 20c21f4..16f2b64 100644 --- a/src/main/resources/templates/upload.html +++ b/src/main/resources/templates/upload.html @@ -13,7 +13,7 @@
-
+