Comments (3)
Hello @wanze,
I didn't recognize the hookability… fantastico, that did it. Now I fetch the formatted output of the og_image field and processwire fetches the defined default values @field-settings.
This hooking scenario also provides a solution for another usecase I recently had: inherit values from the next available parent in page tree. That's useful in a deep nested tree where you have topic nodes of which values should be reflected on their childpages.
Thank you!
My simple hook in ready.php
$this->addHookAfter('SeoMaestro::renderSeoDataValue', function (HookEvent $event) {
$group = $event->arguments(0);
$name = $event->arguments(1);
$value = $event->arguments(2);
$page = $event->wire('page');
if ($group === 'opengraph' && $name === 'image') {
if ($value !== "") return;
//scenario 1: fetch default image assigned in field-settings (get formatted)
$value = $page->og_image;
//scenario 2: inherit from next upper parent-page in tree with assigned image (no setting for default value @og_image)
// $selector = "og_image!=''";
// $value = $page->og_image ?: $page->closest($selector)->og_image;
$event->return = $value;
}
});
from seomaestro.
Hi @esszett,
I moved your question to a new issue to keep things organized a bit.
That is very interesting, I actually didn't know about the feature to select a default value for the an image field. I think you are right, the fallback might only work when output formatting is on. I will look how to support this scenario. Or maybe you found it out already? :) In the meantime, you could rebuild this logic by hooking into the rendering process of the meta data. There are two hooks available, I am not sure which one is easier to use, see the test cases here: https://github.com/wanze/SeoMaestro/blob/master/tests/src/SeoMaestroTest.php#L83-L132
In your hook, you would need to return the url of the default image, if no image has been specified. Hope that helps!
Cheers
from seomaestro.
@esszett FYI, the fallback to the default page image is now respected by the module in version 0.7.0
.
from seomaestro.
Related Issues (20)
- Render structured data for breadcrumbs HOT 1
- Add possibility to always include the website name in the meta title HOT 1
- Recommended meta description length HOT 1
- Multi language aware meta_title_format
- German Umlauts should not be encoded HOT 1
- SeoDataBase encode issue HOT 5
- How to use with "Media Manager" plugin? HOT 4
- One line incompatible with PHP version less than 7.0 HOT 1
- Global Defaults HOT 1
- Multiple og:images
- Canonical url default
- Support image fields that are nested, i.e. hero_fieldset.hero_image
- Ability to set canonical URL HOT 1
- Seo image is duplacated multiple times
- PHP 8.1 errors HOT 3
- [Feature Request] Meta Image as Image Field HOT 5
- Replace ?? with ? and : to support lower PHP versions to match ProcessWire HOT 1
- Module uses max-sized raw version of given image-field if set as placeholder {image} HOT 1
- Display problems with Inputfield on newest ProcessWire versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seomaestro.