From 80fb92cac9feb1f271d900384225e46e2b1ebba8 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Mon, 13 Nov 2017 09:46:54 +0000 Subject: [PATCH 1/2] Fix image link generation --- app/Media.php | 13 ++++++++++++- changelog.md | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Media.php b/app/Media.php index 8e30109b..84ba10c2 100644 --- a/app/Media.php +++ b/app/Media.php @@ -50,6 +50,7 @@ class Media extends Model public function getMediumurlAttribute() { $basename = $this->getBasename($this->path); + $extension = $this->getExtension($this->path); return config('filesystems.disks.s3.url') . '/' . $basename . '-medium.' . $extension; } @@ -62,6 +63,7 @@ class Media extends Model public function getSmallurlAttribute() { $basename = $this->getBasename($this->path); + $extension = $this->getExtension($this->path); return config('filesystems.disks.s3.url') . '/' . $basename . '-small.' . $extension; } @@ -69,11 +71,20 @@ class Media extends Model public function getBasename($path) { $filenameParts = explode('.', $path); - $extension = array_pop($filenameParts); + // the following achieves this data flow // foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar $basename = ltrim(array_reduce($filenameParts, function ($carry, $item) { return $carry . '.' . $item; }, ''), '.'); + + return $basename; + } + + public function getExtension($path); + { + $parts = explode('.', $path); + + return array_pop($parts); } } diff --git a/changelog.md b/changelog.md index 4f2825d9..ac9d1b01 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # Changelog +## Version {next} + - Fix issue with generating image links from images uploaded to `/api/media` + ## Version 0.12.5 (2017-11-09) - Fix style of tags on bookmarks page that had been visited - Fix style of notes listed on `/notes/tagged/tag` From f995a2f1acf6e6261ed81c1eebb0149e068c7ef2 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Mon, 13 Nov 2017 09:47:23 +0000 Subject: [PATCH 2/2] Bump version number to 0.12.6 --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index ac9d1b01..7c1f688e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ # Changelog -## Version {next} +## Version 0.12.6 (2017-11-13) - Fix issue with generating image links from images uploaded to `/api/media` ## Version 0.12.5 (2017-11-09)