If you have a gallery 2.0 embedded in your drupal site through the gallery module you can easily customize blocks which present pictures from your albums. Please note that this is an addition to the gallery module's own image block.

This is an example that displays a number of recent pictures. Through css you can have the pictures line up horisontally.

  1. Go to administer > blocks, click the tab at the top > "add block".
  2. Give the block a title. This title displays in the block with the images, so your users will see it.
  3. Under the "input format" section, click "PHP code". If you don't see "PHP code" listed as an option, maybe you need to enable it in administer > input formats. If you don't click PHP code, it won't work!
  4. next, in the "block body" section of "add block", paste in the following code:
    <div class="gallery-block">
    <?php
    	list ($success, $ret) = _gallery_init(true);
    	if (!$success) {
    		gallery_error(t('Unable to initialize embedded Gallery'), $ret);
    		return;
    	}
    	$params['blocks'] = 'recentImage|recentImage|recentImage|recentImage|recentImage|recentImage|recentImage|recentImage|recentImage|recentImage';
        $params['show'] = implode('|', variable_get('gallery_block_show_' . $delta, array()));
    	$params['maxSize'] = 160;
    	
    	list($ret, $content, $head) = GalleryEmbed::getImageBlock($params);
    	if ($ret->isError()) {
    		gallery_error(t('Unable to get Gallery image block'), $ret);
    		return;
    		} else {
    			print $content;
    		}
    	
    	$ret = GalleryEmbed::done();
    ?>
    </div>
    
  5. Type in a brief description and then click "save block".
  6. Have a look at http://codex.gallery2.org/index.php/Gallery2:GalleryEmbed:getImageBlock or the embedded gallery's Image Block Settings page to see other options.

    hints: if you want to display random images from your gallery, instead of recent images, change the word "recentImage" to "randomImage" everywhere it appears in the code. the code displays 10 images; if you want fewer images, delete a "|recentImage"...be sure to delete the "|", eh? be careful you don't delete the single quote and semi-colon at the end of the line.

    problems? if you have a WYSIWYG editor installed, like TinyMCE, you must disable it before you save your block. WYSIWYG editors will hash up the code.