Difference between revisions of "How to Create Cover Images in EPrints 3"

From EPrints Documentation
Jump to: navigation, search
Line 4: Line 4:
 
=== Create a new document type "coverimage" ===
 
=== Create a new document type "coverimage" ===
  
Add following line to [[eprints3/archives/ARCHIVEID/cfg/namedsets/]]document
+
Add following line to [[Archives/ARCHIVEID/cfg/namedsets/]]document
  
 
  cover_image
 
  cover_image

Revision as of 17:38, 15 January 2007

This describes how to generate cover images on the abstract pages. Cover images are rendered differently from other document types.

Create a new document type "coverimage"

Add following line to Archives/ARCHIVEID/cfg/namedsets/document

cover_image

Add a phrase to

/opt/eprints3/archives/ARCHIVEID/cfg/lang/en/phrases/document_formats.xml
<epp:phrase id="document_typename_cover_image">Cover Image</epp:phrase>

Add phrases for all other languages your repository supports.

When you deposit an image, EPrints 3 should automatically create thumbnails for you, of different sizes.

Add rendering of abstract pages

Edit

/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/eprint_render.pl

This is the code that generates the abstract page.

Decide where you want to put the cover image (e.g. next to the citation). Add the following code to simply add an HTML img tag:

# Cover image
foreach my $doc ( $eprint->get_all_documents() )
{
  if( $doc->get_type eq "cover_image" )
  {
    $page->appendChild( $session->make_element(
      "img",
      src => $doc->thumbnail_url( "medium" ),
      alt => "Cover image" ) ); # Size may be one of small, medium, preview
  }
}

Next you might want to keep the cover image from appearing in the list of documents. Look for the lines that says

# Available documents
my @documents = $eprint->get_all_documents();

This part of the code is where the documents get rendered at the top of the abstract page.

A few lines below in the foreach loop add code to stop rendering the cover image:

foreach my $doc ( @documents )
{
  # Do not show cover image in document list.
  next if $doc->get_type eq "cover_image";
  ...


Do not forget to restart Apache!

Restart Apache to make changes effective.

Run generate_abstracts

Run generate_abstracts (you can pass in the ID of a record with a "cover_image" document) and reload the abstract page - you should see the cover image displayed near the top of the page.