ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Joseph Wensley


You must be logged in to post.

PHP Error: Use of undefined constant

Support Request

Imp Designs
Imp Designs

Hello there!

I’m a long time user of imgsizer who is trying to get Img_Resize rolling along but have run into a bit of a snag. The code below currently spits out a nasty PHP Error message!

A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant __DIR__ - assumed ‘__DIR__’

Filename: img_resize/pi.img_resize.php

Line Number: 130

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/kdanc/

Filename: core/Common.php

Line Number: 408

Fatal error: ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers in /home/kdanc/ on line 166

My code is fairly straight forward

{exp:img_resize src="{attorney_image}" width="90" height="115" alt="{title}"

Various other combinations of the same code have also resulted in the same error

{exp:img_resize src="/images/uploads/attorney_images/Heath-Dedmond.jpg" width="90" height="115"

In the above test, I swapped out my EE variable {attorney_image} with the path of a known working image.

I look forward to your help with this!

Joseph W
# 1
Joseph W

Ah, the __DIR__ constant is only available on PHP 5.3+, I will need to look into a fallback for older versions of PHP.

Imp Designs
# 2
Imp Designs

I have found a fix that you can implement into future releases!

Add the following line of code just beneath the $plugin_info array declaration.

if (!defined('__DIR__')) define('__DIR__'dirname(__FILE__)); 

I have tested this and it resolves the issue completely. :)