Menu

#1 URL created with extra underscore

open
nobody
None
5
2007-11-25
2007-11-25
onlds
No

I've spent considerable time customizing FAlbum and have become somewhat familiar with the functions. I ran into an issue where pasting the picture "code" from the ajax modules into a post causes an extra underscore "_" to show up in the image URL.

So when I paste
[fa:p:id=2057729555,j=l,s=s,l=p]

into my post I get a URL like
[farm3.static.flickr.com]

Note: See the double __ underscore there? Where the heck is that coming from?

I've hacked it for now, but it would be nice to know what code is parsing those codes in the post so I could nuke the extra underscore correctly.

Discussion

  • littleram

    littleram - 2008-07-03

    Logged In: YES
    user_id=1089683
    Originator: NO

    It's in here:

    function _create_flickr_image_url($farm, $server, $photo_id, $secret, $size) {
    $url = FALBUM_FLICKR_URL_IMAGE_1."{$farm}".FALBUM_FLICKR_URL_IMAGE_2."/{$server}/{$photo_id}_{$secret}_{$size}.jpg";
    return $url;
    }

    My solution is to add the following line just after the opening function bracket:

    $size = ltrim($size,'_');

    Note that this solution makes no assumptions about the presence of the underscore, albeit for a very slight performance hit.

     
  • littleram

    littleram - 2008-07-03

    Logged In: YES
    user_id=1089683
    Originator: NO

    Actually, my previous solution isn't foolproof. It fails to take into account cases where there isn't a '_' at the end of the URL filename. So here's a better solution:

    if (isset($size) && '' != $size)
    {
    $size = '_' . ltrim($size,'_');
    }
    $url = FALBUM_FLICKR_URL_IMAGE_1."{$farm}".FALBUM_FLICKR_URL_IMAGE_2."/{$server}/{$photo_id}_{$secret}{$size}.jpg";

     

Log in to post a comment.

MongoDB Logo MongoDB