Issue with echoing img_path in a view

edited September 2011 in Modules
I have a view where i'm trying to echo out an image path from a module that I created in the admin panel.

I just have the images currently being saved to /assets/images/galleryImages.

Right now if I try to echo the image like this,

<?php if (!empty($image->image)) : ?> <img src="<?php echo img_path($image->image); ?>" /> <?php endif; ?>

I get the path /mysite/assets/images/image.jpg. I know the path should be /mysite/assets/images/galleryImages/image.jpg.

If I try the code like this

<?php if (!empty($image->image)) : ?> <img src="<?php echo img_path('galleryImages'.$image->image); ?>" /> <?php endif; ?>

I get the path /mysite/fuel/modules/image.jpg/assets/images/galleryImages.

Is the img_path() function not able to handle doing 'text'.$var ?

Comments

  • edited 5:16AM
    The above example looks correct. What looks like is happening is that you are somehow passing the second parameter to img_path() which says which module to look in for creating the path to the image (e.g. echo img_path('galleryImges/image.jpg', 'my_module') would = /mysite/fuel/modules/my_module/assets/images/image.jpg)
  • Yea that's what I figured was happening. If it's appended with a period(.) I would have thought that it would just include it as the first parameter in the img_path() function, but apparently not so.

    In any case, I figured out my issue by comparing with what the demo had.
Sign In or Register to comment.