GetPluginForCurrentPage();
# get the unadultered body of the entry and its images
$Body = $Entry->Get("Body");
$Images = $Entry->Images();
# return the body as-is if there are no images associated with the blog
# entry
if (count($Images) < 1)
{
return $Entry->Body();
}
# get all of the image insertion points
$ImageInsertionPoints = $Entry->GetImageInsertionPoints();
# display all of the images at the top if there are no insertion points
if (count($ImageInsertionPoints) < 1)
{
$ImageInsertionPoints = array(0);
}
# variables used to determine when and where to insert images
$ImagesPerPoint = ceil(count($Images) / count($ImageInsertionPoints));
$ImagesInserted = 0;
$InsertionOffset = 0;
foreach ($Images as $Image)
{
$SafeImage = defaulthtmlentities($Image->PreviewUrl());
$SafeImageAlt = defaulthtmlentities($Image->AltText());
$SafeWidth = defaulthtmlentities($Image->PreviewWidth());
$ImageInsert = '
';
$ImageInsert .= '';
# add the caption if not the default value
if ($Entry->HasCaption($Image))
{
$ImageInsert .= '
'.$SafeImageAlt.'
';
}
$ImageInsert .= '
';
# determine at which insertion point to insert this images
$InsertionPointIndex = floor($ImagesInserted/$ImagesPerPoint);
$ImageInsertionPoint = $ImageInsertionPoints[$InsertionPointIndex];
# insert the image into the body, offsetting by earlier insertions
$Body = substr_replace(
$Body,
$ImageInsert,
$ImageInsertionPoint+$InsertionOffset,
0);
# increment the variables used to determine where to insert the next
# image
$InsertionOffset += strlen($ImageInsert);
$ImagesInserted += 1;
}
# remove the image insertion point
$Body = preg_replace(
'/'.Blog_Entry::BLANK_LINE_REGEX.'{5,}/',
"\n\n", $Body);
# return the body with the images inserted
return $Body;
}
/**
* Print some blog entry metrics.
* @param array $Metrics Array of blog entry metrics.
*/
function Blog_PrintEntryMetrics(array $Metrics)
{
$SafeNumViews = defaulthtmlentities(count($Metrics["Views"]));
$SafeNumEmail = defaulthtmlentities(count($Metrics["Shares/Email"]));
$SafeNumFacebook = defaulthtmlentities(count($Metrics["Shares/Facebook"]));
$SafeNumTwitter = defaulthtmlentities(count($Metrics["Shares/Twitter"]));
$SafeNumLinkedIn = defaulthtmlentities(count($Metrics["Shares/LinkedIn"]));
$SafeNumGooglePlus = defaulthtmlentities(count($Metrics["Shares/Google+"]));
?>
Comments
NumberOfComments() > 0) { ?> Log in to post a comment.There are no comments yet for this entry. Please Log In to post one.