Adding an Image to a Featured Collection/Exhibit

Is there a way to add an image to a featured collection or exhibit in the Berlin theme? I want it so that my featured collections and exhibits have images associated with them (images that are from each respective collection or exhibit), but I'm not sure how to implement that in the code...

There has to be some way to extract a featured image for a collection/exhibit and display that instead of a link...

Doing something like that would require a fair amount of theme customization, in particular to dig up the image. It's a little more straightforward for a collection, since you can search for an item by collection id with get_record(). Digging through exhibits to an item and its image involves a bit more complication.

Either way, the process would be the same regardless of theme, since it would require some customization of the theme. It's doable with some code -- starting with the collection angle and using get_record() is probably the best place to start.

There is no custom.php file in the Berlin theme, so am I on the right track with placing this code into the custom.php file that I have created?

<?php display_random_featured_collection_with_item() {
	<?php echo random_featured_item($withImage); ?>
	<?php echo display_random_featured_collection(); ?>

I'm not sure that I've placed the code in between the { } in the function correctly...

Also, where in the file structure should the custom.php file go?

Thanks for your help, guys!

If custom.php doesn't exist in the theme, just add it in the top level of the theme.

You won't need the <?php inside the function:

<?php display_random_featured_collection_with_item() {
	echo random_featured_item($withImage);
	echo display_random_featured_collection();

Thanks patrickmj! Unfortunately, that function still doesn't retrieve an random image from a collection. I suppose there needs to be more customization within the function... How exactly would the get_record() be implemented?

I found this posting here that seems to detail exactly what I want to do, but it was written three years ago:

I tried the code there (just being hopeful), but it did not work either.