Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter plugins_lexblog

    (@plugins_lexblog)

    Ugh… This is the best I could come up with:

    $user_photo = userphoto__get_userphoto($author_id, USERPHOTO_THUMBNAIL_SIZE, ”, ”, array(), ”);

    You guys gonna go and change that userphoto__get_userphoto() function in an update and break my theme, or what?

    Same question here.

    Also notice int he code you’ve already written the functions to do this, but not made them available.

    Is this likely to be made active soon?

    plugins_lexblog, if you’re worried about future updates breaking your stuff (And so you should be!) a possible solution is to copy that function in it’s entirety to your own functions.php for example.

    Rename it, and change every reference to it in your code to your new name.

    The added benefit of this is you can mess with the function to make it return more of what you specifically want, strip out unnecessary bits if you have the knowhow – For example, to make it return just the SRC of the image and go from there.

    Then if they change their function in future, yours should be left unharmed, which is at least a little bit safer.

    Obviously in an ideal world you wouldn’t do this, but it might give you a little bit more peace of mind if you’re set on going down this route.

    Scott Fennell

    (@scofennellgmailcom)

    (I am the OP on this topic, just not at my work computer right now).

    burtatbase,

    I see you point but the function returns exactly what I want it to, as is.

    I see they named it with a double underscore after the prefix, which in some circles is a convention to denote that it is intended to be a private function, although not truly private in the OOP sense of the word. That has me worried. I think if they mess with the plugin enough to change the arguments for this function, then I’d rather just take another look at the code and once again grab what I need to return an image.

    This worked for me:

    For Thumbnail:
    $photoUrl = get_bloginfo(‘wpurl’) . ‘/wp-content/uploads/userphoto/’ . get_user_meta($userID, ‘userphoto_thumb_file’, true);

    For Full Image:
    $photoUrl = get_bloginfo(‘wpurl’) . ‘/wp-content/uploads/userphoto/’ . get_user_meta($userID, ‘userphoto_image_file’, true);

    This will just get the full URL to the image.

    Thread Starter plugins_lexblog

    (@plugins_lexblog)

    That’s really good.

    Caution, some setups balk at your assumption on where wp-conent is, and require:

    http://codex.wordpress.org/Function_Reference/content_url

    But it seems REALLY unlikely that the plugin devs on wp-photo will change the user_meta key for the image files. Seems very future-proof. Nice work.

    Didn’t know about the content_url function! Took a quick look but didn’t see anything. I’ll keep it in mind for future use.

    Thanks! 😀

    FWIW, I think ‘wp_upload_dir’ would be somewhat more robust:

    For Thumbnail:
    $upload_dir = wp_upload_dir();
    $photoUrl = $upload_dir[‘baseurl’] . ‘/userphoto/’ . get_user_meta($userID, ‘userphoto_thumb_file’, true);

    For Full Image:
    $upload_dir = wp_upload_dir();
    $photoUrl = $upload_dir[‘baseurl’] . ‘/userphoto/’ . get_user_meta($userID, ‘userphoto_image_file’, true);

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: User Photo] How to RETURN photo instead of ECHO photo?’ is closed to new replies.