Skip to content

Commit f329c5c

Browse files
Add [AOPEN] [ACLOSE] placeholders + webp compatibility
1 parent e78d052 commit f329c5c

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

functions.inc.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717

1818
global $allowed_suffixes;
19-
$allowed_suffixes = array('jpg','jpeg','gif','png');
19+
$allowed_suffixes = array('jpg','jpeg','gif','png','webp');
2020

2121
$mod_nwi_file_dir = WB_PATH.MEDIA_DIRECTORY.'/.news_img/';
2222
$mod_nwi_thumb_dir = WB_PATH.MEDIA_DIRECTORY.'/.news_img/thumb/';
@@ -101,7 +101,7 @@ function mod_nwi_get_groups(int $section_id) : array
101101
$group['id_key'] = $group['group_id'];
102102
}
103103
$group['image'] = '';
104-
foreach(array_values(array('png','jpg','jpeg','gif')) as $suffix) {
104+
foreach(array_values(array('png','jpg','jpeg','gif','webp')) as $suffix) {
105105
if (file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news_img/image'.$group['group_id'].'.'.$suffix)) {
106106
$group['image'] = WB_URL.MEDIA_DIRECTORY.'/.news_img/image'.$group['group_id'].'.'.$suffix;
107107
}
@@ -1206,10 +1206,14 @@ function mod_nwi_posts_render($section_id,$posts,$posts_per_page=0)
12061206
$images = mod_nwi_img_get_by_post($post['post_id'],false);
12071207
$anz_post_img = count($images);
12081208
$post_href_link = 'href="'. $post['post_link'].'"';
1209+
$post_a_open_tag = '<a '.$post_href_link.'>';
1210+
$post_a_close_tag = '</a>';
12091211
// no "read more" link if no long content
12101212
if ( (strlen($post['content_long']) < 9) && ($anz_post_img < 1)) {
12111213
$post['post_link'] = '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;';
12121214
$post_href_link ='';
1215+
$post_a_open_tag ='';
1216+
$post_a_close_tag ='';
12131217
}
12141218

12151219
// set replacements for current line
@@ -1223,6 +1227,8 @@ function mod_nwi_posts_render($section_id,$posts,$posts_per_page=0)
12231227
'SHORT' => $post['content_short'],
12241228
'LINK' => $post['post_link'],
12251229
'HREF' => $post_href_link,
1230+
'AOPEN' => $post_a_open_tag,
1231+
'ACLOSE' => $post_a_close_tag,
12261232
'MODI_DATE' => $post['post_date'],
12271233
'MODI_TIME' => $post['post_time'],
12281234
'TAGS' => implode(" ", $tags),
@@ -1889,6 +1895,17 @@ function mod_nwi_image_resize($src, $dst, $width, $height, $crop=0)
18891895
}
18901896
}
18911897
break;
1898+
case 'webp':
1899+
if(!function_exists('imagecreatefromwebp')) {
1900+
return 2;
1901+
} else {
1902+
try{
1903+
$img = imagecreatefromwebp($src);
1904+
} catch (\Exception $e) {
1905+
return 2;
1906+
}
1907+
}
1908+
break;
18921909
default: return 2;
18931910
}
18941911

@@ -1927,6 +1944,7 @@ function mod_nwi_image_resize($src, $dst, $width, $height, $crop=0)
19271944
case 'gif': imagegif($new, $dst); break;
19281945
case 'jpg': imagejpeg($new, $dst); break;
19291946
case 'png': imagepng($new, $dst); break;
1947+
case 'webp': imagewebp($new, $dst); break;
19301948
}
19311949
return true;
19321950
}
@@ -1957,6 +1975,8 @@ function mod_nwi_replacements()
19571975
'IMAGES', // gallery images
19581976
'LINK', // "read more" link
19591977
'HREF', // link to post detail including href=""
1978+
'AOPEN', // complete <a href=""> if long text or gallery exists
1979+
'ACLOSE', // closing </a> if long text or gallery exists
19601980
'MODI_DATE', // post modification date
19611981
'MODI_TIME', // post modification time
19621982
'NEXT_LINK', // next link
@@ -2267,10 +2287,14 @@ function mod_nwi_get_news_items($options=array())
22672287
$images = mod_nwi_img_get_by_post($post['post_id'],false);
22682288
$anz_post_img = count($images);
22692289
$post_href_link = 'href="'. $post['post_link'].'"';
2290+
$post_a_open_tag = '<a '.$post_href_link.'>';
2291+
$post_a_close_tag = '</a>';
22702292
// no "read more" link if no long content
22712293
if ( (strlen($post['content_long']) < 9) && ($anz_post_img < 1)) {
22722294
$post['post_link'] = '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;';
22732295
$post_href_link = '';
2296+
$post_a_open_tag ='';
2297+
$post_a_close_tag ='';
22742298
}
22752299
$posts[] = mod_nwi_post_process($post, $post['section_id'], $users);
22762300
}

info.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616
$module_directory = 'news_img';
1717
$module_name = 'News with Images';
1818
$module_function = 'page';
19-
$module_version = '5.0.13';
19+
$module_version = '5.0.14';
2020
$module_platform = '1.4';
2121
$module_author = 'Ryan Djurovich, Rob Smith, Silvia Reins, Martin Hecht, Florian Meerwinck, Bianka Martinovic';
2222
$module_license = 'GNU General Public License';
2323
$module_description = 'This page type is designed for making a news page with Images and Lightboxeffect.';
2424

2525
/**
26+
*
27+
* v5.0.14 - 2022-02-08
28+
* - florian
29+
* * Add [AOPEN] [ACLOSE] placeholders + webp compatibility
2630
*
2731
* v5.0.13 - 2021-12-25
2832
* - gchriz

readme.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ <h4 id="d722">Beitrag Schleife</h4>
226226
<li>[IMAGE] Beitragsbild (&lt;img src=... /&gt;),</li>
227227
<li>[SHORT] Kurztext,</li>
228228
<li>[LINK] Link zur Beitrags-Detailansicht,</li>
229-
<li>[HREF] gibt den Link zum Beitrag inkl. href="" aus, also z.B. <code>href="beitrag.php"</code>. Gibt es keinen Langtext und keine Galerie, wird nichts ausgegeben. Mit <code>&lt;a [HREF]&gt; ... &lt;/a&gt;</code> ist es dann möglich, den jeweiligen Beitragslink nur dann klickbar zu machen, wenn es auch tatsächlich einen Langtext und/oder eine Galerie gibt.</li>
229+
<li>[HREF] gibt den Link zum Beitrag inkl. href="" aus, also z.B. <code>href="beitrag.php"</code>. Gibt es keinen Langtext und keine Galerie, wird nichts ausgegeben. Mit <code>&lt;a [HREF]&gt; ... &lt;/a&gt;</code> ist es dann möglich, den jeweiligen Beitragslink nur dann klickbar zu machen, wenn es auch tatsächlich einen Langtext und/oder eine Galerie gibt,</li>
230+
<li>[AOPEN] Der komplette &lt;a href="beitrag.php"&gt; Tag, wenn es Langtext oder Galeriebilder gibt, sonst leer,</li>
231+
<li>[ACLOSE] Der schließende &lt;/a&gt; - Tag zu [AOPEN],</li>
230232
<li>[MODI_DATE] Datum der letzten Änderung des Beitrags,</li>
231233
<li>[MODI_TIME] Zeitpunkt (Uhrzeit) der letzten Änderung des Beitrags,</li>
232234
<li>[CREATED_DATE] Datum, wann der Beitrag erstellt wurde,</li>
@@ -409,7 +411,9 @@ <h4>post loop</h4>
409411
<li>[IMAGE] post image (&lt;img src = ... /&gt;),</li>
410412
<li>[SHORT] short text,</li>
411413
<li>[LINK] Link to the article detail view,</li>
412-
<li>[HREF] Link to the detail view including href="" (i.e. <code>href="example-post.php"</code>). If no long content or gallery exists, this placeholder will return an empty string. Depending on the page settings (using <code>&lt;a [HREF]&gt; ... &lt;/a&gt;</code>) links to the detail view are only clickable if some displayable content exists.</li>
414+
<li>[HREF] Link to the detail view including href="" (i.e. <code>href="example-post.php"</code>). If no long content or gallery exists, this placeholder will return an empty string. Depending on the page settings (using <code>&lt;a [HREF]&gt; ... &lt;/a&gt;</code>) links to the detail view are only clickable if some displayable content exists,</li>
415+
<li>[AOPEN]The whole &lt;a href="beitrag.php"&gt; tag, if long text or gallery images exist, otherwise empty,</li>
416+
<li>[ACLOSE] the closing &lt;/a&gt; tag to [AOPEN],</li>
413417
<li>[MODI_DATE] date of the last change of the post,</li>
414418
<li>[MODI_TIME] Time (time) of the last change of the post,</li>
415419
<li>[CREATED_DATE] Date when the post was created,</li>

upgrade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
if(defined('WB_URL'))
1818
{
19-
function nwi_create_new_post($filename, $filetime=NULL, $content )
19+
function nwi_create_new_post($filename, $filetime=NULL, $content='' )
2020
{
2121
global $page_id, $section_id, $post_id;
2222
// The depth of the page directory in the directory hierarchy

0 commit comments

Comments
 (0)