10
10
*
11
11
**/
12
12
13
+ use Joomla \CMS \Factory ;
13
14
use Joomla \CMS \Language \Multilanguage ;
14
15
use Joomla \CMS \Plugin \CMSPlugin ;
15
16
use JUPWA \Helpers \HTML ;
24
25
class PlgJUPWASeblod extends CMSPlugin
25
26
{
26
27
/**
27
- * @since 1.0
28
- * @var \Joomla\CMS\Application\CMSApplication
28
+ * PlgJUPWASeblod constructor.
29
29
*
30
- */
31
- protected $ app ;
32
-
33
- /**
30
+ * @param $subject
31
+ * @param $config
32
+ *
33
+ * @throws \Exception
34
34
* @since 1.0
35
- * @var array
36
35
*/
37
- protected array $ loaded = [];
36
+ public function __construct (&$ subject , $ config )
37
+ {
38
+ parent ::__construct ($ subject , $ config );
39
+
40
+ $ this ->app = Factory::getApplication ();
41
+ $ this ->loaded = [];
42
+ }
38
43
39
44
/**
40
45
* @param $article
@@ -51,9 +56,9 @@ public function onJUPWAArticleSchema($article, $params, $context): void
51
56
$ option = [
52
57
'params ' => $ this ->params ,
53
58
'title ' => $ this ->core ($ article , $ context )->title ,
54
- 'image ' => $ this ->image ($ article , $ params )->image ,
55
- 'image_width ' => $ this ->image ($ article , $ params )->width ,
56
- 'image_height ' => $ this ->image ($ article , $ params )->height ,
59
+ 'image ' => $ this ->image ($ article , $ params, $ context )->image ,
60
+ 'image_width ' => $ this ->image ($ article , $ params, $ context )->width ,
61
+ 'image_height ' => $ this ->image ($ article , $ params, $ context )->height ,
57
62
'description ' => $ this ->core ($ article , $ context )->description ,
58
63
'intro ' => $ this ->core ($ article , $ context )->intro ,
59
64
'article ' => $ article
@@ -92,9 +97,9 @@ public function onJUPWAArticleOG($article, $params, $context): void
92
97
'params ' => $ params ,
93
98
'type ' => $ type ,
94
99
'title ' => $ this ->core ($ article , $ context )->title ,
95
- 'image ' => $ this ->image ($ article , $ context )->image ,
96
- 'image_width ' => $ this ->image ($ article , $ context )->width ,
97
- 'image_height ' => $ this ->image ($ article , $ context )->height ,
100
+ 'image ' => $ this ->image ($ article , $ params , $ context )->image ,
101
+ 'image_width ' => $ this ->image ($ article , $ params , $ context )->width ,
102
+ 'image_height ' => $ this ->image ($ article , $ params , $ context )->height ,
98
103
'description ' => $ this ->core ($ article , $ context )->description
99
104
], [
100
105
'headline ' => $ this ->core ($ article , $ context )->title
@@ -127,32 +132,36 @@ public function onJUPWAArticleTwitter($article, $params, $context): void
127
132
OG ::twitter ([
128
133
'params ' => $ params ,
129
134
'title ' => $ this ->core ($ article , $ context )->title ,
130
- 'image ' => $ this ->image ($ article , $ params )->image ,
131
- 'image_width ' => $ this ->image ($ article , $ params )->width ,
132
- 'image_height ' => $ this ->image ($ article , $ params )->height ,
135
+ 'image ' => $ this ->image ($ article , $ params, $ context )->image ,
136
+ 'image_width ' => $ this ->image ($ article , $ params, $ context )->width ,
137
+ 'image_height ' => $ this ->image ($ article , $ params, $ context )->height ,
133
138
'description ' => $ this ->core ($ article , $ context )->description
134
139
]);
135
140
}
136
141
}
137
142
138
143
/**
139
144
* @param $article
145
+ * @param $params
140
146
* @param $context
141
147
*
142
148
* @return false|object
143
149
*
150
+ * @throws \Exception
144
151
* @since 1.0
145
152
*/
146
- private function image ($ article , $ context ): object |bool
153
+ private function image ($ article , $ params , $ context ): object |bool
147
154
{
148
155
$ image = $ this ->core ($ article , $ context )->image ;
149
156
150
- if ($ image )
157
+ if ($ image !== '' )
151
158
{
152
159
return Images::display ($ image );
153
160
}
154
161
155
- return false ;
162
+ $ default_image = Images::display_default ($ params ->get ('selectimg ' ), $ params ->get ('image ' ), $ params ->get ('imagemain ' ));
163
+
164
+ return Images::display ($ default_image );
156
165
}
157
166
158
167
private function core ($ article , $ context ): object
@@ -215,6 +224,7 @@ public function onJUPWAAccess($context): bool
215
224
}
216
225
217
226
/**
227
+ * @param $id
218
228
* @param null $attr
219
229
*
220
230
* @return array|bool
0 commit comments