Generated og:image: Excluding section/images from consideration

Well, I have something in place to address this specific need, and I was able to limit it mostly to the pages that need it. I’ll share here should it help anyone else in the future.

[in a public module]

public function onBeforeOutput($buffer) { // before widget/xphp processing
  global $_LW;

  // make group id available, continue if defined
  $_LW->applyPageAndGroupVars('<xphp var="group_id"/>');
  if (!empty($GLOBALS['group_id'])) {
		// if group is Core: Admissions and is a page (not details)
		if (($GLOBALS['group_id'] == 37) && (empty($_LW->is_details_template))) {
			// if page content contains "ZeeMee" or "Beloit Bridge" (i.e. a #sidebar-content blurb widget tag)
			$posZM = strpos($buffer, 'ZeeMee');
			$posBB = strpos($buffer, 'Beloit Bridge');
			if ( ($posZM !== false) || ($posBB !== false) ) {
				// set an alternative social share image
				$buffer=str_replace(
				'</head>',
				'<meta data-share-image="https://www.beloit.edu/live/image/gid/94/13377_middle-college-autumn.jpg" />
				</head>',
				$buffer);
			}
		}
  }

  return $buffer;
}

It works, but hoping the LiveWhale folks consider my more ideal solutions as feature ideas. ;D

The ability to influence LiveWhale’s image selection for the image <meta> tags:

  • First try to use an image from #main-content. If none, then default behavior.
  • Never consider images from #sidebar-content.
  • Always use group defined image regardless of page content.
  • etc.

Thanks,
Nick