Jump to content

Recommended Posts

Posted

I have been reading too much to find the answer...

What I now am building is a way for users to upload their avatar. So an image field added to the user template.

  1. Question:
    In site/assets/files I see there are thumbs created. Were are these sizes set.
     
  2. Question:
    If I loop through my user template pages, ususally one get to the image like $page->image (single). But how do I get to the thumb?
Posted

Bwakad,

Moved this here (general support forum) from the FAQ from which is for 'Answers to frequently asked questions about ProcessWire.' :-)

  • Like 1
Posted

In your template, call $page->image->size(80, 100) to get an image with 80px width and 100px height. It's all explained at the images page.

If you've turned on the option for specific image field to display thumbnails in the page editor, ProcessWire will automatically generate some thumbnails (imagename.0x100.jpg), but that doesn't mean anything for you, really.

Posted

I have this code for now which seems to NOT work in the foreach, but when I use the direct path, it does???

I added the field named "image", type set to "image", only allow 1, and attached it to the user template.

$test = $pages->find("template=user");

echo "<ul>";

    foreach($test->image as $image) {
        $thumb = $image->width(300);
        echo "<li><img src='{$thumb->url}' width='$thumb->width' /></a></li>";
}

echo "<li><img src='/site/assets/files/1013/cnn-logo.jpg'></li>";

echo "</ul>";

Posted

Well,  changed the code to this which seems to work:

$test = $pages->find("template=user");
    foreach($test as $member) {
        if($member->image) echo "<img src='{$member->image->url}' />";
    }

But don't really see the difference...

If I use this:  $thumb = $member->image->size(100,100); inside the foreach(), is that good, or do I use it somehow outside?

Posted

If you need an image (or thumb) for each individual member, then using it within foreach loop is just fine.

Also, size() creates the thumb, but you'll still have to call the URL of said thumb; $member->image->size(100,100)->url etc.

Posted

Got it.

I get all the related stuff by only requesting template=user, and go for the image, but is there a chance someone could hack in one way or another and get to other fields in this template, since the template holds username, email, pass ???

$mymembers = $pages->find("template=user");
    foreach($mymembers as $member) {        
        if($member->image) {
            $thumb = $member->image->size(100,100);
            echo "<li><img src='{$thumb->url}' /></a></li>";
        }
    }
Posted

I now, used the slick slider. There is only one issue with the slider: In the initialisation one has to say how many are visible. And space in between get's calculate automatically. This produces a strange layout in foundation. So inside the div for the slider I used a panel, and inside of that 2 columns. Looks pretty cool, and the slider just slide 2 columns at a time!

post-2177-0-50320500-1408123464_thumb.pn

But now I face another challenge and I think I have to start another topic for that ? (admin/mod can tell me)

profile template hold fields such as location, interests.

while this slider get it's values from the user template, image and username.

How do I get fields related to eachother from 2 different templates?

- edit -

Just moved the image field to the member-profile template which is actually better. Then I just have to reference one template for displaying members. And user template only holds the information regarding register and login.

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
  • Recently Browsing   0 members

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