Hello!
I just wanted to share a fix to an uncaught “read” error that may be haunting some of you.
Imgsizer version: 2.6
EE version: 2.0.2pb01
The Scenario
I am using the imgsizer plugin to display profile images. The error occurs when a profile image doesn’t exist and a {photo_url} (or any path) is set in the “src” parameter.
Example:
{exp:imgsizer:size src="images/member_photos/{photo_filename}" width="100"}
PHP throws a “read” error because it can’t read the nonexistent “file”.
I tried to get around the error using conditional template tags and a few other template tricks, but EE parses {exp} tags before anything else, so the error persisted.
In the end, the plugin needed to do the work and check to see if a file was actually given, and not just a path. Here are my updates:
// -------------------------------------
// collect passed vars from the tag
// -------------------------------------
$src = ( ! $this->EE->TMPL->fetch_param('image')) ? ( !$this->EE->TMPL->fetch_param('src') ? '' : $this->EE->TMPL->fetch_param('src') ) : $this->EE->TMPL->fetch_param('image');
$src = str_replace(SLASH, "/", $src); // clean up passed src param
// Check for a file extension
$ext = pathinfo($src, PATHINFO_EXTENSION);
if (!$ext) { $src = false; }
