bwakad Posted August 14, 2014 Share Posted August 14, 2014 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. Question: In site/assets/files I see there are thumbs created. Were are these sizes set. 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? Link to comment Share on other sites More sharing options...
kongondo Posted August 14, 2014 Share Posted August 14, 2014 Bwakad, Moved this here (general support forum) from the FAQ from which is for 'Answers to frequently asked questions about ProcessWire.' 1 Link to comment Share on other sites More sharing options...
teppo Posted August 15, 2014 Share Posted August 15, 2014 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. Link to comment Share on other sites More sharing options...
bwakad Posted August 15, 2014 Author Share Posted August 15, 2014 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>"; Link to comment Share on other sites More sharing options...
Soma Posted August 15, 2014 Share Posted August 15, 2014 If it only is a single image field there's no need for foreach, no? Link to comment Share on other sites More sharing options...
bwakad Posted August 15, 2014 Author Share Posted August 15, 2014 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? Link to comment Share on other sites More sharing options...
teppo Posted August 15, 2014 Share Posted August 15, 2014 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. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted August 15, 2014 Share Posted August 15, 2014 To array or not to be (array) Thats how you configured the image field. As single image or as an array of images. Link to comment Share on other sites More sharing options...
bwakad Posted August 15, 2014 Author Share Posted August 15, 2014 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>"; } } Link to comment Share on other sites More sharing options...
bwakad Posted August 15, 2014 Author Share Posted August 15, 2014 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! 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now