|
A Fix for AidaNews module 'Errore nella creazione della thumbnail' adaptiveresize()

fatal-error.jpg

If you use the Aidanews2 module with Joomla 2.5.x, which is for displaying latest posts, you may at some point have experienced the error that totally disables your website and shows the message as below:

Errore nella creazione della thumbnail
Fatal error: Call to a member function adaptiveResize() on a non-object in /home/homefolder/public_html/modules/mod_aidanews2/helper.php on line 289

This is just frustrating and can cause one to scream a litany of expletives, especially since the developer's website Aimini.it seems to be abandoned and the forum overrun by spam.

The error is caused when the module's parameter Create Thumbnails is enabled and the script detects an <img tag in an article but does not find an actual image at the specified URL to process with PhpThumb.inc.php.

This fix is not a 'perfect' solution but it will certainly keep your website functional, especially if you have multiple publishers who may not be as precise as you the owner. It determines if the image exists for the path in the article and continues the function but returns the default image if the image file is not found.

Open the module's helper file at modules/mod_aidanews2/helper.php

Search for if ($params->get('usethumbs') at line 1076

Edit the line as below

if ($params->get('usethumbs') && file_exists(substr($img1url,0 ,-6)))

Next, add condition option before the existing option

else
if ($params->get('usethumbs') && !file_exists(substr($img1url,0 ,-6))) {
	$h = $params->get('img1H');
	$w = $params->get('img1W');
	$img1url = substr($img1url, 0, strrpos($img1url, '-'));
	$img1url = '<img src="/modules/mod_aidanews2/img/aidadefault1.jpg"';
	if ($w && $w != "auto") $img1url .= ' width="' . $w . '"';
	if ($h && $h != "auto") $img1url .= ' height="' . $h . '"';
	$img1url .= ' alt="' . $row->alias . '"/>';

So the complete coding should appear as

if ($params->get('usethumbs') && file_exists(substr($img1url,0 ,-6))) {
	$img1url = modAiDaNews2Helper::creaThumb($img1url, $params, 1, $row->id, $row->alias);
	list($w, $h) = getimagesize($img1url);
	$img1url = '<img src="' . $img1url . '" width="' . $w . '" height="' . $h . '" alt="' . $row->alias . '"/>';
}else
if ($params->get('usethumbs') && !file_exists(substr($img1url,0 ,-6))) {
	$h = $params->get('img1H');
	$w = $params->get('img1W');
	$img1url = substr($img1url, 0, strrpos($img1url, '-'));
	$img1url = '<img src="/modules/mod_aidanews2/img/aidadefault1.jpg"';
	if ($w && $w != "auto") $img1url .= ' width="' . $w . '"';
	if ($h && $h != "auto") $img1url .= ' height="' . $h . '"';
	$img1url .= ' alt="' . $row->alias . '"/>';
}else{
	$h = $params->get('img1H');
	$w = $params->get('img1W');
	$img1url = substr($img1url, 0, strrpos($img1url, '-'));
	$img1url = '$lt;img src="' . $img1url . '"';
	if ($w && $w != "auto") $img1url .= ' width="' . $w . '"';
	if ($h && $h != "auto") $img1url .= ' height="' . $h . '"';
	$img1url .= ' alt="' . $row->alias . '"/>';
}

You can also add a parameter to the module to be able to use your preferred default image. If you do that you can then replace the path in the condition option with the new variable like this:

$img1url = '<img src="'.$params->get('mydefaultimg').'"';

To add the parameter option

Open modules/mod_aidanews2/mod_aidanews2.xml

Add either of the below lines to any <fieldset as you desire

This will go to the images folder root
<field name="mydefaultimg" type="media" default="images/mydefault.jpg" />

This will go to a specific folder within the images directory
<field name="mydefaultimg" type="media" label="Default Image" default="images/icons/mydefault.jpg" directory="icons" />

CMSEnergizer

 

Copyright © 2018 CMSEnergizer.com. All Rights Reserved.
This website is powered by the Joomla!©™ 3 Website Framework | File download and article manager component by CMSE Custom Fields | Advanced Module Manager and Modules Anywhere by NoNumber Elements | Website hosting and development by WebsiteDons

CMSEnergizer.com is owned and operated by Emuzement Net Inc, Tampa, Florida USA