Image resizing

Hi

I'm trying to resize an avatar; I need to pass an image URL to an external site, but the image needs to be of a given size. 

I'm using: $avatar = "$user->getIconURL('small')";

Would I have to create a custom image size in actions/avatar/upload.php

or

Would I have to create a custom image size in actions/avatar/crop.php???

and if so where would be a good place to start?

thanks in advance

regards

  • OK

    so I used 'custom' => array('w'=>65, 'h'=>65, 'square'=>TRUE, 'upscale'=>TRUE),

    to create my custom image/avatar.

    and used $avatar = "$user->getIconURL('small')";                     avatar_url= ' . $avatar . '      to try to pass the url to the externam site, but the image link is still broken.

    Could this be a chmod issue, and if so, any ideas on a fix that won't cause a security issue as I've read that you have to be careful with permissions in the elggdata dir?

    Any pointers would be greatly appreciated

    regards

  • OK

    I've spotted the issue.  The URL being fetched isn't fully qualified ie http://mysite.com/dir/dir/image.gif

    moreover, my data dir isn't in my root, anybody know how I can fetch the phisical path for  "$user->getIconURL('custom)";?

    Or maybe that won't as it's a phisical path? can I append http:// onto my path and still get the image?

    Or worst case, will I have to change where my upload.php stores avatars, and, will this break all/any other avatars in my site?

    please help i'm slowiy going grey and losing my hair lol

    regards

  • @TW

    I need to be able to fetch the users' personal avatar; which are kept in the data dir.  so I 'guess' I'll need to change the defaule chmod on that dir and its corosponding subdirs.  which make me worry about security.

    any ideas would be greatly appreciated

    regards

  • Create a new page_handler and use headers for download

  • @IK

    I've just spotted another little problem

    when i print $avatar = "$user->getIconURL('small')";

    I get small rather than the url???

    ie

    $avatar = "$user->getIconURL('small')";

    +

    print($avatar)

    =

    small

    ??????

    maybe that was my issue all along?

    as for page handlers and headrs...  I'm just a noob I wouldn't have the first clue where to start, I'm barely stringing things together by geeling stuff from other code and guessing what code means by looking at it.

    so any help would be a great help

    thanks for the advice btw

    regards

     

  • @Stumpy : there are typos in your code. It should be like

    $user = YOU SHOULD MAKE SURE THAT THE ELGG USER EXISTS AND WE HAVE FOUND THE USER.

    $avatar = $user->getIconURL('small');

    echo $avatar // will give you the user avatar URL for the iconsize small

  • @TW

    That should help a great deal

    the user deffinately exists, my guid and name are being past to the externam site fine.

    still ('small') when using echo????

    here's my page as it is at the moment:

    <?php

    $user = elgg_get_logged_in_user_entity();

     

    $name = "$user->name";

    $uid = "$user->guid";

    $gender = "$user->gender";

    $avatar = "$user->getIconURL('small')";

    print('<div align="center"><iframe src="http://www.siteurl.com/channel_auth.asp?v=2&channel_id=123456&uid= ' . $uid . '&nick_name= ' . $name . ' &avatar_url= ' . $avatar . ' $auth_sig=md5(uid+0987654321)..........................................................

    ?>

    thanks again

    regards

  • Ok

    I've figured out a way to do it, but 1st I need to figure out a way to duplicate avatars into a custom graphics dir.

    eg: _graphics/custom_graphics/

    I want to use the same action as upload.php

    Any pointers would be great

    thanks again for the help

    regards

  • I gave you your solution 6 hours ago. Don't waste people's time. You do not need any duplicates, just create a custom page_handler and set your headers to download. That will produce the same effect. Look into files plugin, download page_handler. Your answer is there. In fact, the default icon page_handler does the same thing. So, in stead of looking for complicated ways to solve your problem, figure out why getIconURL is not working for you.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking