We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Problem, Members

Images in the Members App

Hi there,

Just wondering whether you can use images for the members in the members app?

I've added a simple image field to the member.html template it adds the field in Perch but when you save the image it disappears.

And when you call it with

echo perch_member_get('image');

It just outputs nothing, maybe I'm trying something that's not possible?

I'm all up to date.

Dexter Harrison

Dexter Harrison 29 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What does debug output for the page?

Here it is on the page

SELECT * FROM perch2_members_sessions WHERE sessionID='3b6256f6c000c1dc130abdbca5e5603019f6eceb' AND sessionHttpFootprint='e8cded8a6a84eb77fcbce5899df32900ec92a4f9' AND sessionExpires>'2015-05-01 17:51:36' LIMIT 1
User is logged in
SELECT * FROM perch2_pages WHERE pagePath='/admin/core/runway/start.php' LIMIT 1
SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC
Using master page: /templates/pages/home.php
Page arguments:

Here it is after pressing save on the member and adding an image that disappears after saving

SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='2e5edd92f55e20a360573d4f561b563e' LIMIT 1
UPDATE perch2_users SET userHash='20c69b245e2fec132351f5d6b89078ac' WHERE userID=1
SELECT p.privKey FROM perch2_user_privileges p
SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID
SELECT collectionID, collectionKey FROM perch2_collections WHERE collectionInAppMenu=1 ORDER BY collectionOrder ASC
SELECT * FROM perch2_members WHERE memberID=1 LIMIT 1
Using template: /templates/members/member.html
SELECT * FROM perch2_resources WHERE resourceID='1' LIMIT 1
SELECT * FROM perch2_resources WHERE resourceAWOL=0 AND resourceParentID='1' AND resourceKey='thumb'
SELECT * FROM perch2_resources WHERE resourceAWOL=0 AND resourceParentID='1' AND resourceTargetWidth=800 AND resourceTargetHeight=0 AND resourceCrop=0 AND resourceDensity=1
Logging resources for perch_members
DELETE FROM perch2_resource_log WHERE appID='perch_members' AND itemFK='memberID' AND itemRowID=1
INSERT IGNORE INTO perch2_resource_log(`appID`, `itemFK`, `itemRowID`, `resourceID`) VALUES('perch_members','memberID',1,1),('perch_members','memberID',1,2),('perch_members','memberID',1,3)
UPDATE perch2_members SET memberEmail='hello@dexterharrison.com', memberStatus='active', memberCreated='2015-04-29', memberProperties='{\"first_name\":\"Dexter\",\"last_name\":\"Harrison\",\"image\":{\"assetID\":\"1\",\"title\":\"Flat Forms Pack\",\"_default\":\"\\/admin\\/resources\\/flat-forms-pack.jpg\",\"bucket\":\"default\",\"path\":\"flat-forms-pack.jpg\",\"size\":13945,\"w\":460,\"h\":460,\"mime\":\"image\\/jpeg\",\"sizes\":{\"thumb\":{\"w\":\"150\",\"h\":\"150\",\"target_w\":150,\"target_h\":150,\"density\":2,\"path\":\"flat-forms-pack-thumb@2x.jpg\",\"size\":8205,\"mime\":\"\",\"assetID\":\"2\"},\"w800hc0\":{\"w\":\"460\",\"h\":\"460\",\"target_w\":\"800\",\"target_h\":false,\"crop\":false,\"density\":\"1\",\"path\":\"flat-forms-pack-w800.jpg\",\"size\":13945,\"mime\":\"\",\"assetID\":\"3\"}}}}' WHERE memberID=1
No ids to log.
DELETE FROM perch2_members_member_tags WHERE memberID='1'
SELECT t.*, mt.tagExpires FROM perch2_members_member_tags mt, perch2_members_tags t WHERE mt.tagID=t.tagID AND mt.memberID='1' ORDER BY t.tag ASC
SELECT COUNT(*) FROM perch2_members WHERE memberStatus='pending'
Queries: 19
Memory: 3.9345

Ok, i did the force update (even though this was a fresh install) because i saw the perch2_resource_log table was missing in debug.

I now get this on the page


Debug Message SELECT * FROM perch2_members_sessions WHERE sessionID='3b6256f6c000c1dc130abdbca5e5603019f6eceb' AND sessionHttpFootprint='e8cded8a6a84eb77fcbce5899df32900ec92a4f9' AND sessionExpires>'2015-05-01 17:55:16' LIMIT 1 User is logged in SELECT * FROM perch2_pages WHERE pagePath='/admin/core/runway/start.php' LIMIT 1 SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC Using master page: /templates/pages/home.php Page arguments: Array ( [type] => 8 [message] => Array to string conversion [file] => /Users/dharrison/Desktop/davesstag/admin/templates/pages/home.php [line] => 1 )

and now when i try to echo the image it outputs array

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does this return?

print_r(perch_member_get('image'));
Array ( [assetID] => 1 [title] => Flat Forms Pack [_default] => /admin/resources/flat-forms-pack.jpg [bucket] => default [path] => flat-forms-pack.jpg [size] => 13945 [w] => 460 [h] => 460 [mime] => image/jpeg [sizes] => Array ( [thumb] => Array ( [w] => 150 [h] => 150 [target_w] => 150 [target_h] => 150 [density] => 2 [path] => flat-forms-pack-thumb@2x.jpg [size] => 8205 [mime] => [assetID] => 2 ) [w800hc0] => Array ( [w] => 460 [h] => 460 [target_w] => 800 [target_h] => [crop] => [density] => 1 [path] => flat-forms-pack-w800.jpg [size] => 13945 [mime] => [assetID] => 3 ) ) )
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, so:

$image = perch_member_get('image');
echo $image['_default'];

Great that works for member.html, but not if the member adds the image themselves.

This is the debug after the member uploading the image

Debug Message
SELECT * FROM perch2_members_sessions WHERE sessionID='16f2b07f084e5858b298ac0a70a00239612c59bc' AND sessionHttpFootprint='e8cded8a6a84eb77fcbce5899df32900ec92a4f9' AND sessionExpires>'2015-05-02 12:52:02' LIMIT 1
User is logged in
SELECT * FROM perch2_pages WHERE pagePath='/admin/core/runway/start.php' LIMIT 1
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
SELECT * FROM perch2_members WHERE memberID='2' LIMIT 1
SELECT COUNT(*) FROM perch2_members WHERE memberEmail='hello@dexterharrison.com' AND memberID!=2
UPDATE perch2_members SET memberEmail='hello@dexterharrison.com', memberProperties='{\"first_name\":\"Dexter\",\"last_name\":\"Harrison\",\"token\":\"c2494e6e03d5cd9e98a502bb7f9ea950cf238a6a\"}' WHERE memberID=2
No ids to log.
SELECT t.tag FROM perch2_members_tags t, perch2_members_member_tags mt WHERE t.tagID=mt.tagID AND mt.memberID='2' AND (mt.tagExpires IS NULL OR mt.tagExpires>'2015-05-02 12:52:00')
INSERT INTO perch2_members_sessions(sessionID,sessionExpires,sessionHttpFootprint,memberID,sessionData) VALUES('eab096538af9fe81c3a1da6ed6709fd3bc74b579','2015-05-07 12:52:02','e8cded8a6a84eb77fcbce5899df32900ec92a4f9','2','a:12:{s:10:\"first_name\";s:6:\"Dexter\";s:9:\"last_name\";s:8:\"Harrison\";s:5:\"token\";s:40:\"cc9eaa1172811b70f71c863f6d7c89ba321d1911\";s:8:\"memberID\";s:1:\"2\";s:14:\"memberAuthType\";s:6:\"native\";s:12:\"memberAuthID\";s:1:\"2\";s:11:\"memberEmail\";s:24:\"hello@dexterharrison.com\";s:14:\"memberPassword\";s:34:\"$P$Bg5QtOxtG6gTvJAsdz4VQCPzyH6gmV.\";s:12:\"memberStatus\";s:6:\"active\";s:13:\"memberCreated\";s:19:\"2015-05-02 12:23:32\";s:13:\"memberExpires\";N;s:4:\"tags\";b:0;}')
DELETE FROM perch2_members_sessions WHERE sessionExpires < '2015-05-02 12:52:02'
DELETE FROM perch2_members_sessions WHERE sessionID='16f2b07f084e5858b298ac0a70a00239612c59bc'
SELECT * FROM perch2_members_sessions WHERE sessionID='eab096538af9fe81c3a1da6ed6709fd3bc74b579' AND sessionHttpFootprint='e8cded8a6a84eb77fcbce5899df32900ec92a4f9' AND sessionExpires>'2015-05-02 12:52:02' LIMIT 1
User is logged in
SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC
Using master page: /templates/pages/members/profile.php
Page arguments:
SELECT * FROM perch2_pages WHERE pagePath='/account' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/account' LIMIT 1
SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-004', '000')
Using template: /templates/navigation/item.html
Using template: /templates/members/forms/profile.html
Using template: /templates/members/forms/password.html
Time: 0.0971
Memory: 4.4389
Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you get if they add it themselves?

Nothing at all

Drew McLellan

Drew McLellan 2638 points
Perch Support

An empty string, or null, or an empty array, or something else?

Well null, if i remove everything from the page except the call for the image i get nothing.

An empty set of body tags, as if the id does not exist.

The image doesn't even get uploaded to the resources folder

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ah, ok, so that's a different issue. How are you handling the image upload?

I have this in the profile.html template

<perch:label for="profileImage">Profile Image</perch:label>
<perch:input type="image" label="Profile Image" id="profileImage" />
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, so you're not doing anything to actually process the image?

What do you mean by that? I assumed Perch would process the image itself?

There's nothing in the Docs to say i need to do more http://docs.grabaperch.com/docs/form/template-tags/input/image/

Any news on this?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Those are the docs for forms, not for the Members app. I'm not sure it has anything built in to process images. I'll log it as an enhancement request.

I see, thanks Drew.