Title: [Plugin: NextGEN Gallery] Image path extraction
Last modified: August 19, 2016

---

# [Plugin: NextGEN Gallery] Image path extraction

 *  Resolved [sugardaddy](https://wordpress.org/support/users/sugardaddy/)
 * (@sugardaddy)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-image-path-extraction/)
 * 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](https://wordpress.org/support/users/sugardaddy/)
 * (@sugardaddy)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-image-path-extraction/#post-1317720)
 * 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](https://wordpress.org/support/users/sugardaddy/)
 * (@sugardaddy)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-image-path-extraction/#post-1317769)
 * 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;`
 *  [darthmortar](https://wordpress.org/support/users/darthmortar/)
 * (@darthmortar)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-image-path-extraction/#post-1317989)
 * 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.

## Tags

 * [image path](https://wordpress.org/support/topic-tag/image-path/)
 * [nextgen](https://wordpress.org/support/topic-tag/nextgen/)

 * 3 replies
 * 2 participants
 * Last reply from: [darthmortar](https://wordpress.org/support/users/darthmortar/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-image-path-extraction/#post-1317989)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
