Add Variable to image_thumb function? |
[eluser]invision[/eluser]
Hi, The following works beautifully: Code: echo image_thumb('www.test.com/uploads/test.jpg', 50, 90); but this doesn't: Code: $posts[img] = "test.jpg"; Can someone explain what I'm doing wrong. I'm convinced it's something simple. Many thanks.
[eluser]danmontgomery[/eluser]
You're using a constant as the array index, which I assume should be a string (unless you've defined the 'img' constant for some reason). Also, you're mixing single and double quotes in your concatenation. Single quoted strings are interpreted literally. Code: $posts['img'] = 'test.jpg';
[eluser]invision[/eluser]
Code: Parse error: syntax error, unexpected T_STRING in ...../public_news_id.php on line 5 Line 5 is: Code: echo image_thumb('www.test.com/uploads/".$posts['img']."', 50, 90);
[eluser]invision[/eluser]
[quote author="noctrum" date="1277240004"]You're using a constant as the array index, which I assume should be a string (unless you've defined the 'img' constant for some reason). Also, you're mixing single and double quotes in your concatenation. Single quoted strings are interpreted literally. Code: $posts['img'] = 'test.jpg'; Thanks for the reply. Unfortunately, that suggestion doesn't seem to work either. Instead it makes my file name: 50_90.jpg ?? I definitely have a value in $posts['img'] as I've returned it before using the image_thumb function. Thanks for your help so far folks.
[eluser]invision[/eluser]
Hi, Here's the function I used: http://jrtashjian.com/blog/image-thumbna...deigniter/ Thank you!
[eluser]danmontgomery[/eluser]
That's what the function does: Code: function image_thumb($image_path, $height, $width)
[eluser]invision[/eluser]
Eeeek. Why then should this display the correct image: Code: echo image_thumb('www.test.com/uploads/test.jpg', 50, 90); Or am I missing something obvious? Thanks for your help with this.
[eluser]danmontgomery[/eluser]
No idea, probably because www.test.com/uploads/test.jpg is an invalid path. The image library only works with local paths. |
Welcome Guest, Not a member yet? Register Sign In |