Thumbnail image for random/featured exhibit lists

117 views
Skip to first unread message

Erin Bell

unread,
Jun 2, 2011, 9:32:05 AM6/2/11
to omek...@googlegroups.com
Hi,

Does anyone know of a good method for extracting an image from each exhibit so that it can be used in a list of recent/featured exhibits?

This seems tricky. 

One way might be to add an option to the Exhibit Builder admin interface so that users may choose the image (kind of like the WordPress post_thumbnail() function).

Another might be to somehow figure out the first image being used (if any) in a given exhibit.

I think both would require a fallback to either no image or a default image.

Any ideas on how to proceed, where to start?

Thanks -- Erin

Jeremy Boggs

unread,
Jun 3, 2011, 6:18:50 PM6/3/11
to omek...@googlegroups.com
It would be easier to filter the items results to return items used in a
given exhibit. Here's a gist that includes a function to filter the
items and hooks that function into the 'item_browse_sql' hook in Omeka:

https://gist.github.com/1007255

You could add this code to your ExhibitBuilder's plugin.php file, and
then you should be able to do this to get all the items for a given exhibit:

$items = get_items(array('exhibit' => '20')); // Replace 20 with your
exhibit's ID, or the Exhibit object.

Seems like this would be a handy thing to have in ExhibitBuilder. If
others think so too, we could try to add it in a future release.

Best,
Jeremy

> --
> You received this message because you are subscribed to the Google
> Groups "Omeka Dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/omeka-dev/-/d1UtTzYzUDJObThK.
> To post to this group, send email to omek...@googlegroups.com.
> To unsubscribe from this group, send email to
> omeka-dev+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/omeka-dev?hl=en.

--
Jeremy Boggs · Associate Director of Research · Center for History and
New Media · George Mason University · chnm.gmu.edu · @clioweb

Erin Bell

unread,
Jun 21, 2011, 11:21:54 PM6/21/11
to omek...@googlegroups.com
Thanks Jeremy, this solution worked out great. I hope you guys will consider adding this to the next release, as it could potentially be very useful in other contexts. Thanks again. -- E

nancym

unread,
Jun 22, 2011, 2:57:34 PM6/22/11
to Omeka Dev
Hi,

I also would like to attach an image to the exhibit.
I wonder after you got the $items object, how did you display it in
the exhibit form!
i am new to omeka and I am trying to understand the code.

the goal is to attch an image to each exhibit created.
I appreciate any help.
Thanks

Erin Bell

unread,
Jun 22, 2011, 3:27:27 PM6/22/11
to omek...@googlegroups.com
Not sure exactly what you mean, but here's what I'm doing with the code above (you can ignore the part about the README file, which just outlines that the following function is dependent upon Jeremy's hack to the Exhibit Builder plugin.php). This is pretty messy and has some issues but maybe it will help. If anyone wants to address any of the "todo" items, please do.

//pulls featured exhibits and one image for use in slideshow
//see README file before trying to reuse (requires plugin hack)
function deco_display_exhibit_gallery($exhibits_array=array()){
        $featured_exhibits = array(1,2,3); //todo: figure out how to populate this array using exhibit_builder_get_exhibits(), which throws an error for some reason
        foreach($featured_exhibits as $featured_exhibit){
        $exhibit = exhibit_builder_get_exhibit_by_id($featured_exhibit);
        $items = get_items(array('exhibit' => $featured_exhibit),1);
        if ($items!=null) //todo: make sure that the item also is an image (non-image will probably break function, or at least slideshow)
        {
        set_items_for_loop($items);
        while(loop_items()):
        //get exhibit item
            $index = 0;
            while ($file = loop_files_for_item()):
                if ($file->hasThumbnail()):
                //this makes sure the loop grabs only the first image for the exhibit item
                    if ($index == 0):
                       echo '<div><img src="'.$file->getWebPath('fullsize').'"/>';
                    endif;
                endif;
            endwhile;
        endwhile;
        echo '<div class="showcase-caption">';
        echo /*Exhibit Title and Link*/'<h3><a href="'.$exhibit->slug.'">'.$exhibit->title.'</a></h3>';
        echo /*Exhibit Description Excerpt*/'<p>'.snippet($exhibit->description, 0, 300,exhibit_builder_link_to_exhibit($exhibit, '<br/>...more')).'';
        echo '</p></div></div>';
        }
        else
            {
            //Exhibit with no files
            echo'<div><img src="'.uri('').'/themes/deco/images/poster.jpg" alt="Oops! This exhibit has no preview image" />
            <div class="showcase-caption">
            <h3>'.exhibit_builder_link_to_exhibit($exhibit->slug,$exhibit->title).'</h3>
            <p>'.snippet($exhibit->description, 0, 300,exhibit_builder_link_to_exhibit($exhibit, '<br/>...more')).'</p></div></div>';
            }
        }
    }


Reply all
Reply to author
Forward
0 new messages