Jump to content

Archived

This topic is now archived and is closed to further replies.

Eirik

Having trouble using a defined value

Recommended Posts

So I have this code and it works, what it does is it detects whether or not my thumbnail image is the appropriate resolution.

 

// BOF defining image resolutions

		$smiw = 160;
		$smih = 120;
		//EOF defining image resolutions


		if (tep_not_null($pInfo->products_image_sm)) {
		echo '    ' . tep_draw_separator('pixel_trans.gif', '5', '15') . tep_draw_checkbox_field('delete_previous_image_sm', 'yes', false) . '<font class="smallText"><font color="ff0000">' . TEXT_PRODUCTS_IMAGE_DELETE . '</font><br>';
		// BOF checking images resolution
		$sm_rsz = getimagesize('../images/' . $pInfo->products_image_sm);
		if ($sm_rsz[0] !== $smiw || $sm_rsz[1] !== $smih) { echo '<font class="smallText" color="ff0000"><b>         Warning:</b></font><font class="smallText" color="000000"> Image is an improper resolution. Please ensure image size is ' . SMALL_IMAGE_WIDTH . ' x ' . SMALL_IMAGE_HEIGHT . '.</font>'; }
		// EOF checking image resolution
		 }

 

But as soon as I try and populate the $smiw with SMALL_IMAGE_WIDTH or the $smih with the SMALL_IMAGE_HEIGHT the code breaks, is there a way of doing this?

Share this post


Link to post
Share on other sites

Try using the absolute path (DIR_FS_IMAGES) to the image rather than ../


How do you know when you know what you want to do for the rest of your life?

Share this post


Link to post
Share on other sites

I think you misunderstand, the code works as is. However when I attempt to populate the if statement

 

if ($sm_rsz[0] !== $smiw || $sm_rsz[1] !== $smih)

with the SMALL_IMAGE_WIDTH or height it breaks. So to try and be clear Im trying to either do something like

if ($sm_rsz[0] !== SMALL_IMAGE_WIDTH || $sm_rsz[1] !== SMALL_IMAGE_HEIGHT)

But that doesn't work, but I hope you get my meaning.

 

but you are right about using the defined path, I'll change that.

Share this post


Link to post
Share on other sites

OK. Another stab at it then.

 

I have experienced at times...

 

when I call an include file from inside an included file the defines such as SMALL_IMAGE_WIDTH are not defined.

 

The trouble is resolved by defining the vars inside the file itself. Yes strange but try it and see if that handles it.

 

If anyone can tell me why this occurs I would love to hear the juicy details. I think it occurs because the included files are called via relative path rather than absolute path ( DIR_WS_XXX rather than DIR_FS_XXX.

 

Curious huh?


How do you know when you know what you want to do for the rest of your life?

Share this post


Link to post
Share on other sites

×