I think this would be really cool, and I don't know how to write it myself. It is almost like the "Most recent comments" block, instead I would like to have a "Most recently added image" block (or something along those lines) where the block shows the thumbnail of the newest image and links to it's node. If there is one already, please tell me; if you can help me to make one please tell me also. Thanks.

Comments

bones’s picture

That would be really useful, I would like 5 recent images (thumbs) to be displayed on the front page. Can anyone help in how this might be done?
Thanks

dreamYu’s picture

... i would like to know that too

kbahey’s picture

Here is something I wrote for a client a while back. I quickly updated it from 4.5 to 4.6, and found that it works.

Instructions:

- Save it to a file in your modules directory by the name last_image.module.
- Go to admin/modules and enable it
- Go to admin/settings/last_image to configure it.
- Go to Admin -> Access Control, and grant the permission to roles you want to see this block.
- Go to admin/block, and enable the block.


// Copyright 2004-2005 2bits.com Khalid Baheyeldin

function last_image_help($section) {
  $output ="";

  switch ($section) {
    case 'admin/modules#description':
      $output = t("Displays the last few images added to your site");
      break;
    case 'admin/help#last_image':
    case 'admin/modules/last_image':
      $output = t("This module displays the last few images added to your site, with links to them so users can access the newest added ones quickly.");
      break;
  }

  return $output;
}
  
function last_image_settings()
{
  $output .= form_textfield(t("Number of images to show"), "last_image_show_num",
    variable_get("last_image_show_num", 3), 10, 10,
    t("Number of latest images to show."));  

  $output .= form_textfield(t("Block title text"), "last_image_block_title",
    variable_get("last_image_block_title", t("Last Images")), 35, 255,
    t("The title of the block."));  

  return $output;
}  

function last_image_perm()
{
  return array ("use last_image");
}

function last_image_block($op = 'list', $delta = 0)
{
  $title = variable_get("last_image_block_title", "Last Images");

  switch($op) {
    case 'list':
      $blocks[0]['info'] = t($title);
      return $blocks;

    default:
      switch ($delta) {
        case 0:
          $block['subject'] = t($title);
          if ( user_access('use last_image') ) {
            foreach(image_get_latest(variable_get("last_image_show_num", 3)) as $image) {    
              $output .= '<div id="image">' . 
                l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE) . 
                '</div>';	  
            }    	    
            $content = $output;
          }
	        else {
		        $content = t('You have no permission to access this block');
		      }
        $block['content'] = $content;
        break;
      }
  }
  return $block;
} 

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

dreamYu’s picture

thanks for your input, i'm going to test it if it solves my problems.

leobraga.com.br’s picture

Wt if i need the images from a specific section of my web site? Wt should i do?
This module above works fine... but i need to show only the last images from a couple of sections of my website.
I'm also having problems when i go to the "settings" section on "admin". It gives me a blank page... But that's is not really a trouble cus' i've been setting on the ".module". But if anyone could help me here too... :)

I'm using drupal 4.7.3

Thank you all guys! One of the greatest things about drupal is this solid community