Jump to content

child image path


Xpn
 Share

Recommended Posts

Hi There,

Is it possible to get the child image path?

Now it only output the image file name but not the path to the image it self.

Thanks,

Xpn

<div id="portfolio-content" class="sort fourcol">            
            <?php
            foreach($page->children as $child)
            echo "
                <div class=''>
                <div class='port-item-container'>
                    <div class='port-box'>
                        <div class='zoom-holder'>
                            <img src='{$child->overviewimg}'>
                                <a href='{$child->overviewimgbig}' class='fancybox' title='Title'>
                                    <div class='zoom'>
                                        <div class='zoom-inner'></div>
                                    </div>
                                </a>
                        </div>
                    </div>
                    <div class='port-item-title'>
                        <h6><a rel='bookmark' title='{$child->title}' href='{$child->url}'>{$child->title}</a></h6>
                        <span>{$child->overviewtxt} <a href='{$child->url}'> More info. »</a></span>
                    </div>
                </div>
                </div>
                ";
                ?>
</div>

Link to comment
Share on other sites

Hi Xpn and welcome to Processwire.

Accessing the url for the image is as easy as:

$child->overviewimg->url

The only caveat to that is how your overviewimg field is set up. If the Max Files Allowed setting (Details tab) is set to anything but 1, you will need to use one of the following;

$child->overviewimg->first()->url
$child->overviewimg->last()->url
$child->overviewimg->eq(x)->url //where x is the number of the image in the array of images, starting with 0 as the first.

Also, have a read of:

http://processwire.com/api/fieldtypes/images/

Link to comment
Share on other sites

Just installed the Thumbnails Module anybody familiar with the module?

I would like the use the thumb instead of the normal image .

Can this code some how be used to get the child image thumb path?

$page->cropImages->eq(0)->getThumb('thumbnail');

Something like: {$child->overviewimgbig->cropImages->eq(0)->getThumb('thumbnail')->url}

Thanks,

Xpn

Link to comment
Share on other sites

I tried that and also:

$child->overviewimgbig->eq(0)->getThumb('thumbnail')->url

But it give

Error: Call to a member function eq() on a non-object

I watched the video very nice and easy way to get a portfolio up and running :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...