Customizing single-page view

The single-page view is a bit of a neglected child. It’s main purpose is to provide a static link to an image that can be easily shared on social media. But there is more!

With Backlight 2, the internal classes photo and album are exposed.

// Parses texts and replaces text links with real URLs. Used to display them in single-page view.
function to_url($text) {
   return preg_replace('@(http)?(s)?(://)?(([-\w]+\.)+([^\s]+)+[^,.\s])@', '<a href="http$2://$4">$1$2$3$4</a>', $text);

function single_bottom() {
   if ($this->hasPhoto()) {
      echo '<p>
      echo '<strong>Image Infos:</strong><br/>';
      echo 'Filename: '.$this->photo->getFilename().'<br/>';
      echo 'Dimensions: '.$this->photo->getPhotoHeight().'w x '.$this->photo->getPhotoHeight().'h<br/>';
      echo 'Title: '.$this->photo->getMetadata(Photo::$PHOTO_TITLE).'<br/>';
      echo 'Caption: '.to_url($this->photo->getMetadata(Photo::$PHOTO_CAPTION)).'<br/>';
      echo 'Metadata 1: '.to_url($this->photo->getMetadata("metadata_one")).'<br/>';
      echo 'Metadata 2: '.to_url($this->photo->getMetadata("metadata_two")).'<br/>';
      if (hasLocation()){
         echo 'Latitude: ' . $this->photo->getLatitude(() .' ';
         echo 'Longitude: ' .  $this->photo->getLongitude(() .' ';
         echo '<a href="'. getMapsURL() .'>Map</a>';
      } else {
         echo 'No location data';
      echo '</p>';

   echo '<strong>Parrent album infos:</strong>';
   echo '<p>';
   echo 'Album title: .'$this->album->getTitle().'<br/>';
   echo 'Description: .'$this->album->getDescription().'<br/>';
   echo 'Slug: .'$this->album->getSlug().'<br/>';
   echo 'Number of photos : .'$photo->album->getNumberOfPhotos().'<br/>';
   echo '</p>';

   return true;

Did you like this post? Did you use the given code? Please consider supporting me by buying me a coffee!

Buy Me A Coffee


2 thoughts on “Customizing single-page view”

    1. Yes, this would be part of your phplugins file. Obviously, you would need to modify it according to your preferences.

      Maybe just

      function single_bottom() {
      if ($this->hasPhoto()) {
      echo ‘<p>
      echo ‘Title: ‘.$this->photo->getMetadata(Photo::$PHOTO_TITLE).'<br/>’;
      echo ‘Caption: ‘.to_url($this->photo->getMetadata(Photo::$PHOTO_CAPTION)).'<br/>’;
      echo ‘</p>’;
      return true;

Leave a Reply to daniel Cancel reply

Your email address will not be published. Required fields are marked *

Web Design Consulting

Do you need help designing your web site or getting Backlight working the way you want? Contact me to discuss your idea or project.

Buy me a Coffee

If you like what I share here, please consider buying me a coffee or a print. This helps keeping me motivated to continue posting. Thank you!

Buy Me A Coffee