diff --git a/public_html/article.php b/public_html/article.php
index 5dac1311c..92a02f03f 100644
--- a/public_html/article.php
+++ b/public_html/article.php
@@ -528,7 +528,35 @@ function extractExternalLinks($text) {
$properties['keywords'] = $article->DisplayElements('meta_keywords');
$properties['commentCount'] = CMT_commentCount($article->getSid(), 'article');
$_STRUCT_DATA->add_type('article', $article->getSid(), $article->displayElements('structured_data_type'), $properties);
- $_STRUCT_DATA->set_author_item('article', $article->getSid(), $article->DisplayElements('username'));
+ $_STRUCT_DATA->set_author_item('article', $article->getSid(), $article->DisplayElements('username'));
+ // Include any images attached to the article (taken in part from renderImageTags function in article class)
+ $result = DB_query("SELECT ai_filename,ai_img_num FROM {$_TABLES['article_images']} WHERE ai_sid = '{$article->getSid()}' ORDER BY ai_img_num");
+ $numRows = DB_numRows($result);
+
+ $stdImageLoc = true;
+ if (!strstr($_CONF['path_images'], $_CONF['path_html'])) {
+ $stdImageLoc = false;
+ }
+
+ for ($i = 1; $i <= $numRows; $i++) {
+ $A = DB_fetchArray($result);
+
+ $imgPath = '';
+
+ if ($stdImageLoc) {
+ $imgPath = substr($_CONF['path_images'], strlen($_CONF['path_html']));
+ $imgSrc = $_CONF['site_url'] . '/' . $imgPath . 'articles/' . $A['ai_filename'];
+ } else {
+ $imgSrc = $_CONF['site_url'] . '/getimage.php?mode=articles&image=' . $A['ai_filename'];
+ }
+
+ $sizeAttributes = COM_getImgSizeAttributes($_CONF['path_images'] . 'articles/' . $A['ai_filename'], false);
+ if (is_array($sizeAttributes)) {
+ $_STRUCT_DATA->set_image_item('article', $article->getSid(), $imgSrc, $sizeAttributes['width'], $sizeAttributes['height']);
+ } else {
+ $_STRUCT_DATA->set_image_item('article', $article->getSid(), $imgSrc);
+ }
+ }
$display = COM_createHTMLDocument(
$display,
diff --git a/public_html/lib-common.php b/public_html/lib-common.php
index 3404fbbec..f036eb098 100644
--- a/public_html/lib-common.php
+++ b/public_html/lib-common.php
@@ -6715,10 +6715,11 @@ function COM_convertDate2Timestamp($date, $time = '')
/**
* Get the HTML for an image with height & width
*
- * @param string $file full path to the file
- * @return string html that will be included in the img-tag
+ * @param string $file full path to the file
+ * @param boolean $html flag to return html source or array
+ * @return string if $html true then html that will be included in the img-tag. Else an array will be returned with the information
*/
-function COM_getImgSizeAttributes($file)
+function COM_getImgSizeAttributes($file, $html = true)
{
$sizeAttributes = '';
@@ -6743,15 +6744,24 @@ function COM_getImgSizeAttributes($file)
}
if (($width !== '?') && ($height !== '?')) {
- $sizeAttributes = 'width="' . $width . '" height="' . $height . '" ';
+ if ($html) {
+ $sizeAttributes = 'width="' . $width . '" height="' . $height . '" ';
+ } else {
+ $sizeAttributes['width'] = $width;
+ $sizeAttributes['height'] = $height;
+ }
}
}
} else {
// Other file type
$dimensions = getimagesize($file);
if (!empty($dimensions[0]) && !empty($dimensions[1])) {
- $sizeAttributes = 'width="' . $dimensions[0]
- . '" height="' . $dimensions[1] . '" ';
+ if ($html) {
+ $sizeAttributes = 'width="' . $dimensions[0] . '" height="' . $dimensions[1] . '" ';
+ } else {
+ $sizeAttributes['width'] = $dimensions[0];
+ $sizeAttributes['height'] = $dimensions[1];
+ }
}
}
}
diff --git a/system/classes/structureddata.class.php b/system/classes/structureddata.class.php
index cca925cdb..f21e08150 100644
--- a/system/classes/structureddata.class.php
+++ b/system/classes/structureddata.class.php
@@ -216,7 +216,7 @@ public function set_author_item($type, $id, $name)
* @param string $type Plugin of the content used to create the structured data
* @param string $id Id of content
*/
- public function set_image_item($type, $id, $url, $width, $height)
+ public function set_image_item($type, $id, $url, $width = '', $height = '')
{
$sd_name = $this->create_name($type, $id);