diff --git a/code/ShareCare.php b/code/ShareCare.php index d704062..33ae759 100755 --- a/code/ShareCare.php +++ b/code/ShareCare.php @@ -154,7 +154,7 @@ public function GooglePlusShareLink() */ public function PinterestShareLink() { - $pinImage = ($this->owner->hasMethod('getPinterestImage')) ? $this->owner->getPinterestImage() : $this->owner->getOGImage(); + $pinImage = ($this->owner->hasMethod('getPinterestImage')) ? $this->owner->getPinterestImage() : $this->owner->getMainOGImage(); if ($pinImage) { // OGImage may be an Image object or an absolute URL $imageURL = rawurlencode((is_string($pinImage)) ? $pinImage : $pinImage->getAbsoluteURL()); @@ -198,7 +198,7 @@ public function getTwitterMetaTags() ."\n"; // If we have a big enough image, include an image tag. - $image = $this->owner->getOGImage(); + $image = $this->owner->getMainOGImage(); // $image may be a string - don't generate a specific twitter tag // in that case as it is probably the default resource. if ($image instanceof Image && $image->getWidth() >= 280) { @@ -236,6 +236,20 @@ public function getDefaultOGTitle() return $this->owner->getTitle(); } + /** + * Get the main OG image (even if it's an array of images) + * + * @return string + */ + public function getMainOGImage() + { + $image = $this->owner->getOGImage(); + if (is_array($image)) { + $image = $image[0]; + } + return $image; + } + /** * The default/fallback Image object or absolute URL to be used in the 'og:image' open graph tag. * diff --git a/templates/ShareCarePreview.ss b/templates/ShareCarePreview.ss index c39f3f6..0d59aeb 100644 --- a/templates/ShareCarePreview.ss +++ b/templates/ShareCarePreview.ss @@ -45,22 +45,22 @@
-
-

Facebook / Twitter / Google+

-
- <% if $OGImage %> -

- <% if $OGImage.SetWidth(300) %> - $OGImage.SetWidth(300) - <% else %> - - <% end_if %> -

- <% end_if %> - - -
-
+
+

Facebook / Twitter / Google+

+
+ <% if $MainOGImage %> +

+ <% if $MainOGImage.SetWidth(300) %> + $MainOGImage.SetWidth(300) + <% else %> + + <% end_if %> +

+ <% end_if %> + + +
+
<% if $IncludePinterest %>