• I was looking into using a plugin for this, but then realized WP’s features + PHP’s features allow for more direct “grabbing” of posts that flickr automatically adds if they are sent via a cell-phone.
    What I do first is set category 1 to my “moblog”, and category 2 becomes my web-based posted updates. In options, I set the default category to “2”.
    What this does is now anything flickr posts automatically is a “category 1” post, but anything I manually post via WP (or even a “blog this! in flickr) is a category 2.
    Got it so far?

    Okay, now we will parse our “category 1” posts in a sidebar, get the images, and do whatever with them.


    <?php
    //Proportional thumbnail creation
    function imageResize($width, $height, $target) {
    if ($width > $height) {
    $percentage = ($target / $width);
    } else {
    $percentage = ($target / $height);
    }
    $width = round($width * $percentage);
    $height = round($height * $percentage);
    return "width="$width" height="$height"";
    }

    //Get posts belonging to moblog category
    query_posts('cat=1');

    //Create "THE LOOP"
    while (have_posts()) : the_post();

    //Put post content into a string
    $flickr = get_the_content($more_link_text, $stripteaser, $more_file);

    //Extract the img URL to another string "$imgurl[1]"
    preg_match("|src="(.*?)" alt|",$flickr,$imgurl);

    //Get img's size into another string for resizing function
    $resizewh = getimagesize($imgurl[1]);
    ?>

    Look! An image:
    <img src=<?=$imgurl[1]?>>

    <?php endwhile; ?>

    Why the imageresize function? Well I prefer my images to be thumbnailed a bit, and have a “tooltip” function that will display the full-size image in a popup-box when you mouseover them. So my html code to make a thumbnail is:

    <img src=<?=$imgurl[1]?> <?=imageResize($resizewh[0], $resizewh[1], 50);?>>

    That makes the maximum dimension (width or height) no greater than 50.

    Of course, you can add anything you want to the html section (hyperlink the image to the newspost, for example).
    I just felt like sharing this, hope you understand it… I’m new to the whole WP/PHP thing.

    Here’s an img of it in action:
    https://mywebpages.comcast.net/gbatools/flickrbar.jpg
    (CSS Xray filter, border, etc. added to thumbnail’s style, javascript tooltip popup on mouseover, mouseover contains the img url <?=$imgurl[1]?>)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi the first part is really clear, then it gets hazy.. where does all this code go? The link for a demo it not very clear:-( Thanks for postingthis.. if I canwork it out it will be great! Could you slow down that crazy mind of your and take us through it step by step!

    Cheers

    Thread Starter em158

    (@em158)

    Sorry about that.

    I’ve actually put mine in my sidebar code.

    It’s in its own file (flickrpost.php), which I reference with an include in my sidebar.php:

    <!-- Flickr History -->
    <?php require("c:/wwwroot/wp/wp-content/themes/mine/flickrpost.php"); ?>

    Sorry it took a bit to reply.

    Ok, so my sidebar goes before my content. the extra query_posts() call means that my main loop now doesn’t work as it should do. Is there a function there to “reset” query_posts() to whatever it was when the page started loading?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Flickr sidebar code for cell-phone posts’ is closed to new replies.