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

From EPrints Documentation
Jump to: navigation, search
m (1. Create a new document type "coverimage")
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Beware: This is work in progress!'''
+
[[Category:Howto]]
 
+
 
This describes how to generate cover images on the abstract pages. Cover images are
 
This describes how to generate cover images on the abstract pages. Cover images are
 
rendered differently from other document types.
 
rendered differently from other document types.
  
=== 1. Create a new document type "coverimage" ===
+
=== Create a new document type "coverimage" ===
  
Add following line to /opt/eprints3/archives/<archive_id>/cfg/namedsets/document
+
Add following line to [[Archives/ARCHIVEID/cfg/namedsets/|/opt/eprints3/archives/ARCHIVEID/cfg/namedsets/]]document
  
 
  cover_image
 
  cover_image
Line 12: Line 11:
 
Add a phrase to  
 
Add a phrase to  
  
  /opt/eprints3/archives/<archive_id>/cfg/lang/en/phrases/document_formats.xml
+
  [[archives/ARCHIVEID/cfg/lang/en/phrases/|/opt/eprints3/archives/ARCHIVEID/cfg/lang/en/phrases/]]document_formats.xml
  
 
  <epp:phrase id="document_typename_cover_image">Cover Image</epp:phrase>
 
  <epp:phrase id="document_typename_cover_image">Cover Image</epp:phrase>
Line 18: Line 17:
 
Add phrases for all other languages your repository supports.
 
Add phrases for all other languages your repository supports.
  
=== 2. Add rendering of abstract pages ===
+
When you deposit an image, EPrints 3 should automatically create thumbnails for you, of different sizes.
 +
 
 +
=== Add rendering of abstract pages ===
 +
 
 +
Edit
 +
 
 +
[[eprint_render.pl|/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.
  
Still to come!
+
=== Run generate_abstracts ===
  
=== 3. Do not forget to restart Apache! ===
+
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.

Latest revision as of 15:13, 8 February 2010

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 /opt/eprints3/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.