Publishing ebooks on a WordPress site

Publishing ebooks on a WordPress site

For the recently launched 'Ribbon Factory Library Wall' project it came to publishing the ebooks we were using a WordPress site for the project, which doesn't support epub files out of the box. This was relatively straightforward to work around but just something to be aware of.

the WordPress Media library only supports certain file types by default. For documents, this is limited to:

  • .pdf (Portable Document Format; Adobe Acrobat)
  • .doc, .docx (Microsoft Word Document)
  • .ppt, .pptx, .pps, .ppsx (Microsoft PowerPoint Presentation)
  • .odt (OpenDocument Text Document)
  • .xls, .xlsx (Microsoft Excel Document)

(see the full list here including audio and image file types)

In order to include other types of media in your library, you need to modify the MIMEtypes that your WordPress site can handle. This can be done using the upload_mimes filter hook. Find out more about this filter at: http://codex.wordpress.org/Plugin_API/Filter_Reference/upload_mimes

You will need to add something similar to this to your theme functions.php file to tell WordPress what additional filetypes you want to upload via the Media Library. The mimetypes for epub and mobi files are:

application/x-mobipocket-ebook and for .epub format is application/epub+zip

    function add_custom_mime_types($mimes){
        return array_merge($mimes,array (
          'epub' => 'application/epub+zip',
          'mobi' => 'application/x-mobipocket-ebook '
        ));
      }
    add_filter('upload_mimes','add_custom_mime_types');

You will also need to create or modify your .htaccess file to accept these file types.

    AddType application/epub+zip .epub
    AddType application/x-mobipocket-ebook .mobi

hattip: http://wordpress.stackexchange.com/questions/42669/how-to-upload-and-allow-downloads-of-mobi-and-epub-formats

  1. ebooks
  2. epub
  3. WordPress
  4. pressbooks
  5. snippets