Skip to content

Commit 263bc61

Browse files
committed
Fixed post block so that featured image is no longer cached between block calls
1 parent 0756a93 commit 263bc61

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"magento/magento-composer-installer": "*"
77
},
88
"type": "magento2-module",
9-
"version": "0.1.4",
9+
"version": "0.1.5",
1010
"autoload": {
1111
"files": [
1212
"src/registration.php"

src/Block/Post.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,13 @@ public function getPostUrl()
5151

5252
public function getFeaturedImage()
5353
{
54-
if (!$this->hasData('featured_image')) {
55-
$post = $this->getPost();
54+
$post = $this->getPost();
5655

57-
if (!$post->getFeaturedMedia()) {
58-
$this->setData('featured_image', '');
59-
} else {
60-
$media = $this->mediaApi->getEntity($post->getFeaturedMedia());
61-
$this->setData('featured_image', $media->getSourceUrl());
62-
}
56+
if (!$post->getFeaturedMedia()) {
57+
$this->setData('featured_image', '');
58+
} else {
59+
$media = $this->mediaApi->getEntity($post->getFeaturedMedia());
60+
$this->setData('featured_image', $media->getSourceUrl());
6361
}
6462

6563
return $this->getData('featured_image');

src/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Skywire_WordpressApi" setup_version="0.1.4">
3+
<module name="Skywire_WordpressApi" setup_version="0.1.5">
44
</module>
55
</config>

0 commit comments

Comments
 (0)