Need to Display Page Thumbnail URL (SMO Meta Tags)
Permalink
Hey all,
I need to echo out the page thumbnail's full URL for a particular meta tag. I plan to do this in the header of an existing website. Call me crazy, but I've tried everything I know to make this work but have been very unsuccessful.
Can someone please help me? Thanks all!
I need to echo out the page thumbnail's full URL for a particular meta tag. I plan to do this in the header of an existing website. Call me crazy, but I've tried everything I know to make this work but have been very unsuccessful.
Can someone please help me? Thanks all!

This is what I have done in the past for 5.6, this code goes into a package controller
Hutman,
Thanks for the quick reply. I really appreciate it. I probably should've mentioned that this is for a 5.7.5.6 website. My apologies.
Is there anything that can be done for this version?
Thanks for the quick reply. I really appreciate it. I probably should've mentioned that this is for a 5.7.5.6 website. My apologies.
Is there anything that can be done for this version?
This should work for that version in the controller
use Page; use Events; use View; public function on_start(){ Events::addListener('on_before_render', function () { $view = View::getInstance(); $c = Page::getCurrentPage(); //don't do this if we're in the dashboard or don't have a valid page if(is_object($c) && !$c->isError() && !$c->isSystemPage()){ $thumbnailImage = $c->getAttribute('thumbnail'); if($thumbnailImage){ $view->addHeaderItem('<meta property="og:image" content="'.$thumbnailImage->getURL().'" />'); } } });
Viewing 15 lines of 16 lines. View entire code block.
I honestly do not know where to place the PHP. I'm not a developer. Isn't there a way to place this using just the header_required.php or in the header_top.php as all pages have thumbnails?
You can put this in your header_top.php in your theme by just doing this
$c = Page::getCurrentPage(); $thumbnailImage = $c->getAttribute('thumbnail'); if($thumbnailImage){ echo '<meta property="og:image" content="'.$thumbnailImage->getURL().'" />'; }
Hutman!!!!!! You are awesome. Thank you so much. That did the trick perfectly.
@foundry
In addition to hutman's answer, there is an excellent free add-on for adding Open Graph metadata to your pages.
Open Graph Tags Lite by hissy
https://www.concrete5.org/marketplace/addons/open-graph-tags-lite1...
In addition to hutman's answer, there is an excellent free add-on for adding Open Graph metadata to your pages.
Open Graph Tags Lite by hissy
https://www.concrete5.org/marketplace/addons/open-graph-tags-lite1...