Not signed in ( Sign In)

Categories

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorvoln
    • CommentTimeMay 1st 2010
     permalink
    I am looking for a Flickr widget for FlatPress like this http://blog.wbou.de/flatpress
    Is anyone know about it?
    •  
      CommentAuthorrikriz
    • CommentTimeJun 4th 2010
     permalink
    You can read this post

    the solution is that: create the file plugin.randomheadimg.php

    <?php
    /*
    Plugin Name: randomheadimg
    Version: 0.1
    Plugin URI: http://blog.wbou.de
    Author: Paul Wellner Bou
    Author URI: http://blog.wbou.de
    */

    add_action('wp_head', 'plugin_randomheadimg_head', 0);

    function plugin_randomheadimg_head() {
    $imgdir = dirname(__FILE__).DIRECTORY_SEPARATOR.'imgs'.DIRECTORY_SEPARATOR;
    $dh = opendir($imgdir);
    $imgs = array();
    while (($file = readdir($dh)) !== false) {
    if(is_dir($imgdir.$file) || $file == '.' || $file == '..')
    continue;
    if(preg_match("/\.(jpg|png|gif)$/i", $file))
    $imgs[] = $file;
    }

    if(count($imgs) == 0)
    return;

    $selected_index = rand(1, count($imgs));
    $selected_img = plugin_geturl('randomheadimg').'imgs/'.$imgs[$selected_index];

    echo <<<RANDOMHEADIMGHEAD
    <!-- start of randomheadimg -->
    <style type="text/css"> #head { background-image: url('$selected_img') !important; } </style>
    <!-- end of randomheadimg -->
    RANDOMHEADIMGHEAD;
    }

    ?>


    Create folder plugins/randomheadimg/put plugin.randomheadimg.php file in this folder and create folder plugins/randomheadimg/imgs/ when you'll put your pictures.