public function sliderExhibitAttachment($attachment) { $item = $attachment->getItem(); $file = $attachment->getFile(); if ($file) { if (!isset($fileOptions['imgAttributes']['alt'])) { $fileOptions['imgAttributes']['alt'] = metadata($item, array('Dublin Core', 'Title'), array('no_escape' => true)); } if ($forceImage) { $imageSize = isset($fileOptions['imageSize']) ? $fileOptions['imageSize'] : 'square_thumbnail'; $image = file_image($imageSize, $fileOptions['imgAttributes'], $file); $html = exhibit_builder_link_to_exhibit_item($image, $linkProps, $item); } else { if (!isset($fileOptions['linkAttributes']['href'])) { $fileOptions['linkAttributes']['href'] = exhibit_builder_exhibit_item_uri($item); } $html = file_markup($file, $fileOptions, null); } } else { if ($item) { $html = exhibit_builder_link_to_exhibit_item(null, $linkProps, $item); } } // Don't show a caption if we couldn't show the Item or File at all if (isset($html)) { if (!is_string($attachment['caption']) || $attachment['caption'] == '') { return ''; } $html .= '<div class="exhibit-item-caption">' . $attachment['caption'] . '</div>'; return apply_filters('exhibit_attachment_caption', $html, array('attachment' => $attachment)); } else { $html = ''; } return apply_filters('exhibit_attachment_markup', $html, compact('attachment', 'fileOptions', 'linkProps', 'forceImage')); }
/** * Return the markup for displaying an exhibit attachment. * * @param ExhibitBlockAttachment $attachment * @param array $fileOptions Array of options for file_markup * @param array $linkProps Array of options for exhibit_builder_link_to_exhibit_item * @param boolean $forceImage Whether to display the attachment as an image * always Defaults to false. * @return string */ public function exhibitAttachment($attachment, $fileOptions = array(), $linkProps = array(), $forceImage = false) { $item = $attachment->getItem(); $file = $attachment->getFile(); if ($file) { if (!isset($fileOptions['imgAttributes']['alt'])) { $fileOptions['imgAttributes']['alt'] = metadata($item, array('Dublin Core', 'Title'), array('no_escape' => true)); } if ($forceImage) { $imageSize = isset($fileOptions['imageSize']) ? $fileOptions['imageSize'] : 'square_thumbnail'; $image = file_image($imageSize, $fileOptions['imgAttributes'], $file); $html = exhibit_builder_link_to_exhibit_item($image, $linkProps, $item); } else { if (!isset($fileOptions['linkAttributes']['href'])) { $fileOptions['linkAttributes']['href'] = exhibit_builder_exhibit_item_uri($item); } $html = file_markup($file, $fileOptions, null); } } else { if ($item) { $html = exhibit_builder_link_to_exhibit_item(null, $linkProps, $item); } } // Don't show a caption if we couldn't show the Item or File at all if (isset($html)) { $html .= $this->view->exhibitAttachmentCaption($attachment); } else { $html = ''; } return apply_filters('exhibit_attachment_markup', $html, compact('attachment', 'fileOptions', 'linkProps', 'forceImage')); }
/** * Return a link to an item within an exhibit. * * @param string $text Link text (by default, the item title is used) * @param array $props Link attributes * @param Item $item If null, will use the current item. * @return string */ function exhibit_builder_link_to_exhibit_item($text = null, $props = array(), $item = null) { if (!$item) { $item = get_current_record('item'); } if (!isset($props['class'])) { $props['class'] = 'exhibit-item-link'; } $uri = exhibit_builder_exhibit_item_uri($item); $text = !empty($text) ? $text : strip_formatting(metadata($item, array('Dublin Core', 'Title'))); $html = '<a href="' . html_escape($uri) . '" ' . tag_attributes($props) . '>' . $text . '</a>'; $html = apply_filters('exhibit_builder_link_to_exhibit_item', $html, array('text' => $text, 'props' => $props, 'item' => $item)); return $html; }
public function filterExhibitAttachmentMarkup($html, $options) { $item = $options['attachment']->getItem(); if ($item === null) { return; } if (fc_isFedoraStream($item)) { $uri = exhibit_builder_exhibit_item_uri($item); $dom = fc_displayObject($item); if ($dom->documentElement->tagName == 'img') { $caption = $options['attachment']->caption; $caption = strip_tags($caption, '<br>'); $el = $dom->documentElement; $el->setAttribute('alt', $caption); $el->setAttribute('title', $caption); } $img = $dom->saveHTML(); $html = "<a href=\"{$uri}\" class=\"exhibit-item-link\">{$img}</a>" . get_view()->exhibitAttachmentCaption($options['attachment']); } return $html; }