UPDATES EasyBlog 6.0.11 Released! Update to the latest version now!

Helpdesk

Your Time
Our Time
Response Time
24 — 48 hours
We strive to provide the fastest ever response possible. However, we are not super beings.

Allow at least 24 — 48 hours
  Support is offline
It is currently off working hours and most of us aren't around

Rest assured that we will get back to you as soon as the day starts tomorrow!
It is currently a public holiday for us from where we are at.

There may be a delay in our responses but rest assured that we will be back at full speed when we are back to the office.
  Support is offline

Custom Code Breaking Change

Christopher Ambler · ·
11:26 PM Monday, 20 September 2021
High
Please find, below, some custom code that you guys helped provide a while back. Given the path to an image, this processes the image so it can be used as a post cover. As of this beta, this code is now breaking.

Specifically, this code is throwing an error:


// Read the external image file
$connector = EB::connector();


I suspect you've made a breaking change. Could you please advise?


public static function downloadImage(string $url, $post): ?stdClass
{
$config = EB::config();

if (!$config) {
return null;
}

// Store the image on a temporary location
$temporaryPath = JPATH_ROOT . '/tmp/' . md5($url);

// Read the external image file
$connector = EB::connector();
$connector->addUrl($url);
$connector->execute();

$contents = $connector->getResult($url);

// Save the image to a temporary location
JFile::write($temporaryPath, $contents);

// Prepare the image data
$file = getimagesize($temporaryPath);
$file['name'] = basename($url);
$file['tmp_name'] = $temporaryPath;
$file['type'] = $file['mime'];

$media = EB::mediamanager();
$uri = 'user:' . $post->created_by;

$adapter = $media->getAdapter($uri);
$result = $adapter->upload($file);

// Delete the temporary file
JFile::delete($temporaryPath);

if (!isset($result->type)) {
return null;
}

$path = $config->get('main_image_path');
$path = rtrim($path, '/');

$relative = $path . '/' . $post->created_by;

$relativeImagePath = $relative . '/' . $file['name'];
$result->html = '<img src="' . $relativeImagePath . '" />';

return $result;
}
The replies under this section are restricted to logged in users or users with an active subscription with us