Get image path (src) from image block in a Known Area
Permalink
HI All,
The underlying issue is I would like to provide an "image" for the SEO Structured Data andhttps://search.google.com/structured-data/testing-tool... says image is missing.
I know the page has an area for the user to drop an image block for the logo. I would like to include that path as part of the data,
I know the area name. How do I check for an image block? If found get the filename of the image? (In PHP code at the Page Controller Level.
Thanks,
Sean
The underlying issue is I would like to provide an "image" for the SEO Structured Data andhttps://search.google.com/structured-data/testing-tool... says image is missing.
I know the page has an area for the user to drop an image block for the logo. I would like to include that path as part of the data,
I know the area name. How do I check for an image block? If found get the filename of the image? (In PHP code at the Page Controller Level.
Thanks,
Sean
Nope sorry, nothing to do with Open Graph.
This is the relatively new "structured data" schema that "tells search engines what your data is".
See here:
https://developers.google.com/search/docs/guides/intro-structured-da...
However, that has nothing to do with my question. I am really just trying to find a way to get the path to an image in an image block in a page area.
Thanks,
Sean
This is the relatively new "structured data" schema that "tells search engines what your data is".
See here:
https://developers.google.com/search/docs/guides/intro-structured-da...
However, that has nothing to do with my question. I am really just trying to find a way to get the path to an image in an image block in a page area.
Thanks,
Sean
@SeanDevoy
You can try this:
You can try this:
<?php // get the area object using the area name $areaObject = $c->getArea('Header Site Title'); // get the blocks in the area object $areaBlocks = $areaObject->getAreaBlocks(); // loop through the array of area blocks foreach ($areaBlocks as $block) { // if the current block has the block handle of "image" if ($block->btHandle == 'image') { // get the block's instance $blockInstance = $block->getInstance(); // use the Image block controller getFileID() method to see if there is a selected image if ($blockInstance->getFileID()) { // if there is a selected image, get its file ID $fileID = $blockInstance->getFileID();
Viewing 15 lines of 23 lines. View entire code block.
Perfect!
Thanks so much.
Thanks so much.
please mark as "best answer" for future searches.
Are you trying to use an Open Graph protocol og:image? Where each page has its own unique image?
Example:
If so, I recommend using the Open Graph Tags Lite add-on by hissy. It will handle all of this for you.
https://www.concrete5.org/marketplace/addons/open-graph-tags-lite1/...