items/show.php is broken after upgrade to 1.0beta

Hi,

I just updated to the latest release and all went well except that items/show.php seems to be broken.

I am using a modified version of the Berlin theme and don't think I changed anything in this particular file. It was working fine with .10 and 1.0 alpha.

Anyone know what happened here?

Here's a link:
http://tinyurl.com/ojvye7 (in development)

Thanks -- Erin

I isolated the problem. It's here:

<div id="item-images">

		<?php 

		$files = $item->Files;

		$first_file = $files[0];

		if(!empty($first_file) && $first_file->hasThumbnail()) {
			$html = fullsize($first_file,array('id'=>'item-image'));

			if(count($files)>1) {
				$html .= '<div id="item-images-thumbs">';
				foreach($files as $file) {
					if($file->hasThumbnail()) {
						$html .= '<a href="'.file_download_uri($file).'" class="download-file">';
						$html .= square_thumbnail($file, array('class'=>'thumb'));
						$html .= '</a>';
					}

				}
				$html .= '</div>';
			}
		} else {
			$html = display_files($item->Files);
		}

		echo $html;

		?>
		</div>

Maybe there are some deprecated functions?

Here's the equivalent of what you were doing (an image gallery, I presume) using the latest version of the themes API:

<?php $index = 0; ?>
	<?php while ($file = loop_files_for_item()): ?>
	    <?php if ($file->hasThumbnail()): ?>
	        <?php if ($index == 0): ?>
    	       <?php echo display_file($file, array('imageSize'=>'fullsize')); ?>
    	    <?php else: ?>
    	        <?php echo display_file($file, array('imageSize'=>'square_thumbnail', 'linkToFile'=>true)); ?>
    	    <?php endif; ?>
    	    <?php $index++; ?>
	    <?php endif; ?>
	<?php endwhile; ?>

Kris,

Thanks. This helps a lot. The page is now displaying more or less as expected... BUT...

For some reason, the fullsize image function (called at the top of the item page) is returning a thumbnail link. It is somehow being assigned a new class (.download-file)on its own. I have removed all styles for the class, and the image returns to normal, but I lose control over the ACTUAL download file. I'm sure I can find a way around this by adding a new div but it would be helpful if someone could explain what is actually happening?

Thanks again -- Erin

Could you copy/paste the offending code line? That will give me a bit better sense of what's going on.

Sorry this is going to be a messy looking post.

Here is the items/show.php code:
`
<?php head(array('title' => item('Dublin Core', 'Title'),'javascript'=>js('resize'),'bodyid'=>'items','bodyclass' => 'show item')); ?>

<div id="primary">

<h1><?php echo item('Dublin Core', 'Title'); ?></h1>

<ul class="title-list">
<h3>All Titles</h3>
<?php foreach (item('Dublin Core', 'Title', 'all') as $title): ?>
<li class="item-title">
<?php echo $title; ?>

<?php endforeach ?>

<div id="item-metadata">
<div id="item-images">

<?php $index = 0; ?>
<?php while ($file = loop_files_for_item()): ?>
<?php if ($file->hasThumbnail()): ?>
<?php if ($index == 0): ?>
<?php echo display_file($file, array('imageSize'=>'fullsize')); ?>
<?php else: ?>
<?php echo display_file($file, array('imageSize'=>'square_thumbnail', 'linkToFile'=>true)); ?>
<?php endif; ?>
<?php $index++; ?>
<?php endif; ?>
<?php endwhile; ?>
</div>

<!-- The following function prints all the the metadata associated with an item: Dublin Core, extra element sets, etc. See http://omeka.org/codex or the examples on items/browse for information on how to print only select metadata fields. -->
<?php echo show_item_metadata( array('show_empty_elements' => false) ); ?>

</div><!-- end item-metadata -->
<!-- The following returns all of the files associated with an item. -->
<div id="itemfiles" class="element">
<h3>Files</h3>
<div class="element-text"><?php echo display_files_for_item(); ?></div>
</div>

<!-- If the item belongs to a collection, the following creates a link to that collection. -->
<?php if ( item_belongs_to_collection() ): ?>
<div id="collection" class="element">
<h3>Collection</h3>
<div class="element-text"><p><?php echo link_to_collection_for_item(); ?></p></div>
</div>
<?php endif; ?>

<!-- The following prints a list of all tags associated with the item -->
<?php if(item_has_tags()): ?>
<div id="item-tags" class="element">
<h3>Tags</h3>
<div class="element-text"><?php echo item_tags_as_string(); ?></div>
</div>
<?php endif;?>

<!-- The following prints a citation for this item. -->
<div id="item-citation" class="element">
<h3>Citation</h3>
<div class="element-text"><?php echo item_citation(); ?></div>
</div>
<?php echo plugin_append_to_items_show(); ?>
<ul class="item-pagination navigation">
<li id="previous-item" class="previous">
<?php echo link_to_previous_item('Previous Item'); ?>

<li id="next-item" class="next">
<?php echo link_to_next_item('Next Item'); ?>

</div><!-- end primary -->

<?php foot(); ?>
'
And here is the resize.js that is called in the head. Note that this file was meant to go with the original code on show.php (seen in second post in this series) and that I have tried removing the call to no effect.
'
function ReSize(imgobj){
// Area = width*height
// AspectRatio = width/height
// Area=width*width/AspectRatio
// width= square root(Area*AspectRatio)
longside = 558;

if (imgobj.width > imgobj.height ) {

area=imgobj.width/imgobj.height;

imgobj.width=longside;
var newHeight =longside/area;

imgobj.height=newHeight;

} else { // portrait & square

area=imgobj.height/imgobj.width;

imgobj.height=longside;

var newWidth =longside/area;

imgobj.width=newWidth;

}

}

function resizeThumbs() {
if(!document.getElementsByTagName || !document.getElementById || !document.getElementsByTagName("img")) return;
var itemimage = $("item-image");
ReSize(itemimage);
}

Event.observe(window,'load',function() {
resizeThumbs();
});
'

Hi, I'm still not sure I understand what's going wrong here. The only call to display the fullsize image that I can see is from the example I gave in a previous post. Is that the one you're referring to?

Otherwise, if you could tell me the specific line that you think is causing a problem then I'd be happy to take a look.

Kris,

The problem was easily fixed by taking your new code and adding some divs around the thumbs.

It just seems strange to me that the page broke with the upgrade. It happened on two sites on two different servers, each using some minor variation on the Berlin theme. It also seems odd that the class .download-file is assigned to both the full size and thumbnail images. This was not the case before.

Anyway, it's fixed. Thank you.

useful tips