• Resolved sugardaddy

    (@sugardaddy)


    Hi,

    I’d like to use the wonderful widget’s capabilities of NGG to randomly display a picture on my blog. But I’d like to extract only the image path to use it as a css background.

    Actually, I’m trying with the shortcode provided by the plugin : <?php nggDisplayRandomImages(); ?>

    But… I didn’t find anything about extracting the image url with this shortcode without modifying the plugin code. Or with a bit of javascript manipulation ??

    Any idea ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sugardaddy

    (@sugardaddy)

    Ok I did it but it’s a huge modification of the widgets.php file.
    In fact, what I did is a non reversible modification ?? and it cut definitely the whole encapsulation of the image, keeping only the url or the img tag, depending of the output you choose.

    Here’s what I did (between lines 386 and 420 of widgets.php) :
    – comment encapsulation
    – adding an else if for the case I choose just the image URL


    echo $before_widget . $before_title . $title . $after_title;
    //echo "\n" . '<div class="ngg-widget entry-content">'. "\n";

    if (is_array($imageList)){
    foreach($imageList as $image) {
    // get the URL constructor
    $image = new nggImage($image);

    // get the effect code
    $thumbcode = $image->get_thumbcode("sidebar_".$number);

    // enable i18n support for alttext and description
    $alttext = htmlspecialchars( stripslashes( nggGallery::i18n($image->alttext) ));
    $description = htmlspecialchars( stripslashes( nggGallery::i18n($image->description) ));

    //TODO:For mixed portrait/landscape it's better to use only the height setting, if widht is 0 or vice versa
    //$out = 'imageURL . '" title="' . $description . '" ' . $thumbcode .'>';
    // Typo fix for the next updates (happend until 1.0.2)
    $options[$number]['show'] = ( $options[$number]['show'] == 'orginal' ) ? 'original' : $options[$number]['show'];

    if ( $options[$number]['show'] == 'original' )
    $out .= '<img src="'.NGGALLERY_URLPATH.'nggshow.php?pid='.$image->pid.'&width='.$options[$number]['width'].'&height='.$options[$number]['height']. '" title="'.$alttext.'" alt="'.$alttext.'" />';
    else if ( $options[$number]['show'] == 'imageurl' )
    $out .= NGGALLERY_URLPATH.'nggshow.php?pid='.$image->pid;
    else
    $out .= '<img src="'.$image->thumbURL.'" width="'.$options[$number]['width'].'" height="'.$options[$number]['height'].'" title="'.$alttext.'" alt="'.$alttext.'" />';

    //echo $out . ''."\n";
    echo $out;

    }
    }

    //echo '</div>'."\n";
    echo $after_widget;

    Hope this could help !

    Thread Starter sugardaddy

    (@sugardaddy)

    And if you have some problems with the url syntax, you can change :

    $out .= NGGALLERY_URLPATH.'nggshow.php?pid='.$image->pid;

    to :

    $out .= $image->imageURL;

    To have the absolute path to the original image.
    I needed it to use timthumb with a random image in a css background, which give (inline css only) :

    background:url(<?php echo bloginfo('template_url'); ?>/timthumb.php?src=<?php nggDisplayRandomImages('1','960','180','allow','1','imageurl') ?>&w=960&h=180&zc=1) no-repeat;

    I use multiply random images, is their a way to change it so that all (multiply) images are cropped and resized with TimThumb?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: NextGEN Gallery] Image path extraction’ is closed to new replies.