diff --git a/src/Models/Entities/PostEntity.php b/src/Models/Entities/PostEntity.php index 9807102c..5fb47abc 100644 --- a/src/Models/Entities/PostEntity.php +++ b/src/Models/Entities/PostEntity.php @@ -13,8 +13,8 @@ class PostEntity extends AbstractEntity implements IValidatable protected $safety; public $hidden; public $uploadDate; - public $imageWidth; - public $imageHeight; + protected $imageWidth; + protected $imageHeight; public $uploaderId; protected $source; public $commentCount = 0; @@ -187,6 +187,26 @@ class PostEntity extends AbstractEntity implements IValidatable $this->hidden = boolval($hidden); } + public function getImageWidth() + { + return $this->imageWidth; + } + + public function setImageWidth($imageWidth) + { + $this->imageWidth = $imageWidth; + } + + public function getImageHeight() + { + return $this->imageHeight; + } + + public function setImageHeight($imageHeight) + { + $this->imageHeight = $imageHeight; + } + public function getName() { return $this->name; @@ -308,14 +328,14 @@ class PostEntity extends AbstractEntity implements IValidatable case 'image/jpeg': list ($imageWidth, $imageHeight) = getimagesize($srcPath); $this->setType(new PostType(PostType::Image)); - $this->imageWidth = $imageWidth; - $this->imageHeight = $imageHeight; + $this->setImageWidth($imageWidth); + $this->setImageHeight($imageHeight); break; case 'application/x-shockwave-flash': list ($imageWidth, $imageHeight) = getimagesize($srcPath); $this->setType(new PostType(PostType::Flash)); - $this->imageWidth = $imageWidth; - $this->imageHeight = $imageHeight; + $this->setImageWidth($imageWidth); + $this->setImageHeight($imageHeight); break; case 'video/webm': case 'video/mp4': @@ -325,8 +345,8 @@ class PostEntity extends AbstractEntity implements IValidatable case 'video/3gpp': list ($imageWidth, $imageHeight) = getimagesize($srcPath); $this->setType(new PostType(PostType::Video)); - $this->imageWidth = $imageWidth; - $this->imageHeight = $imageHeight; + $this->setImageWidth($imageWidth); + $this->setImageHeight($imageHeight); break; default: throw new SimpleException('Invalid file type "%s"', $this->mimeType); @@ -363,8 +383,8 @@ class PostEntity extends AbstractEntity implements IValidatable $this->mimeType = null; $this->fileSize = null; $this->fileHash = $youtubeId; - $this->imageWidth = null; - $this->imageHeight = null; + $this->setImageWidth(null); + $this->setImageHeight(null); $thumbPath = $this->getThumbDefaultPath(); if (file_exists($thumbPath)) diff --git a/src/Models/PostModel.php b/src/Models/PostModel.php index 57584610..99e3d59a 100644 --- a/src/Models/PostModel.php +++ b/src/Models/PostModel.php @@ -54,8 +54,8 @@ class PostModel extends AbstractCrudModel 'safety' => $post->getSafety()->toInteger(), 'hidden' => $post->hidden, 'upload_date' => $post->uploadDate, - 'image_width' => $post->imageWidth, - 'image_height' => $post->imageHeight, + 'image_width' => $post->getImageWidth(), + 'image_height' => $post->getImageHeight(), 'uploader_id' => $post->uploaderId, 'source' => $post->getSource(), ]; diff --git a/src/Views/post-file-render.phtml b/src/Views/post-file-render.phtml index 21542ed3..6d4847b0 100644 --- a/src/Views/post-file-render.phtml +++ b/src/Views/post-file-render.phtml @@ -24,8 +24,8 @@ $post = $this->context->transport->post; diff --git a/src/Views/post-view.phtml b/src/Views/post-view.phtml index c2654710..029843f7 100644 --- a/src/Views/post-view.phtml +++ b/src/Views/post-view.phtml @@ -134,12 +134,12 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0; - context->transport->post->imageWidth > 0): ?> + context->transport->post->getImageWidth()): ?>
Dimensions: + $this->context->transport->post->getImageWidth(), + $this->context->transport->post->getImageHeight()) ?>">
diff --git a/tests/JobTests/EditPostContentJobTest.php b/tests/JobTests/EditPostContentJobTest.php index 5a588805..2c134197 100644 --- a/tests/JobTests/EditPostContentJobTest.php +++ b/tests/JobTests/EditPostContentJobTest.php @@ -19,8 +19,8 @@ class EditPostContentJobTest extends AbstractTest $post = $this->uploadFromFile('image.jpg'); $this->assert->areEqual('image/jpeg', $post->mimeType); $this->assert->areEqual(PostType::Image, $post->getType()->toInteger()); - $this->assert->areEqual(320, $post->imageWidth); - $this->assert->areEqual(240, $post->imageHeight); + $this->assert->areEqual(320, $post->getImageWidth()); + $this->assert->areEqual(240, $post->getImageHeight()); $this->assert->doesNotThrow(function() use ($post) { $post->generateThumb(); @@ -34,8 +34,8 @@ class EditPostContentJobTest extends AbstractTest $post = $this->uploadFromFile('image.png'); $this->assert->areEqual('image/png', $post->mimeType); $this->assert->areEqual(PostType::Image, $post->getType()->toInteger()); - $this->assert->areEqual(320, $post->imageWidth); - $this->assert->areEqual(240, $post->imageHeight); + $this->assert->areEqual(320, $post->getImageWidth()); + $this->assert->areEqual(240, $post->getImageHeight()); $this->assert->doesNotThrow(function() use ($post) { $post->generateThumb(); @@ -49,8 +49,8 @@ class EditPostContentJobTest extends AbstractTest $post = $this->uploadFromFile('image.gif'); $this->assert->areEqual('image/gif', $post->mimeType); $this->assert->areEqual(PostType::Image, $post->getType()->toInteger()); - $this->assert->areEqual(320, $post->imageWidth); - $this->assert->areEqual(240, $post->imageHeight); + $this->assert->areEqual(320, $post->getImageWidth()); + $this->assert->areEqual(240, $post->getImageHeight()); $this->assert->doesNotThrow(function() use ($post) { $post->generateThumb();