How does Marfeel detect the images and videos in an article?

Marfeel detects the images and videos an article has to:

  1. Display the main image of an article in Compass view
  2. Compute Image count
  3. Compute Video count

Main image of an article

Marfeel detects the main image of an article following this waterfall process:

  1. LD+JSON data (For more details visit image - Schema.org Property):
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "NewsArticle",
      "image": "mainImage.jpg"
    }
    </script>
    
  2. Microdata
    <img itemprop="image" src="https://domain.com/path/to/img.jpg">
    
  3. Or from Meta OG types:
    <meta property="og:image" content="https://mywebsite.com/images/mainImage.jpg" />
    

Image count

Marfeel calculates the number of images in an article by taking the maximum value among the following counts:

  1. Count the relevant ImageObject in LD+JSON, only from image and associatedMedia entity attributes.
  2. Count the image in Microdata
  3. Count the <img> nodes from a cleaned XPath DOM.
{
  "@type": "ImageObject",

  "url": "mainImage.jpg",

  "width": { // Optional
    "@type": "QuantitativeValue",
    "value": 1000
  },

  "height": { // Optional
    "@type": "QuantitativeValue",
    "value": 1000 
  },

  "name": "Image title", // Optional

  "author": { // Optional
    "@type": "Person",
    "name": "Photographer name"
  }
}

Video count

Marfeel calculates the number of videos in an article by taking the maximum value among the following counts:

  1. Count the relevant VideoObject in LD+JSON, only from video and associatedMedia entity attributes.
  2. Count the video in Microdata
  3. Count the <video> nodes from a cleaned XPath DOM.