Comments (6)
Hi Lari,
I believe this is best achieved through adjusting the property $image_dimensions
.
This is already possible :).
Untested (JIT) example, but here's the idea:
// Set default og:image if featured image not present
add_filter( 'the_seo_framework_og_image_args', 'my_super_awesome_og_image' );
function my_super_awesome_og_image( $args ) {
if( ! has_post_thumbnail() ) {
$args['image'] = home_url( '/FbShare_1200x630.png' );
//* Match the Post/Page/Term ID that's checked for (first and default image only).
$id = the_seo_framework()->get_the_real_ID();
the_seo_framework()->image_dimensions[ $id ] = array(
'width' => '1200',
'height' => '630',
);
}
return $args;
}
from the-seo-framework.
Done!
See: d020cdc
It will output the image width and height beneath every found image, and it's done according to the Array syntax.
It works on the default OG Image, and each WooCommerce Product Gallery image.
Supported image modules:
- Featured Image.
- Header Image.
- Site icon (Customizer WP4.3+)
- WooCommerce Product images
It will be included in the 2.7.0 release :).
from the-seo-framework.
Looks like it works just by copypasting your code. Thank you again!
from the-seo-framework.
Hi Sam,
This is (only) an issue for the first person who shares the page/post.
Nevertheless, I'll see if I can implement this feature in the near future :).
I'll keep you updated right here once more on this issue is known.
from the-seo-framework.
Thanks for the fast reply, yep that is exactly what i need to do!
from the-seo-framework.
Thank you for this feature!
Quick question.
If I don't have a featured image present, I set the og:image with:
// Set default og:image if featured image not present
add_filter( 'the_seo_framework_og_image_args', 'my_awesome_og_image' );
function my_awesome_og_image( $args ) {
if(!has_post_thumbnail()) {
$args['image'] = home_url( '/FbShare_1200x630.png' );
}
return $args;
}
Is there a way to pass the width and height by this filter or another filter?
maybe with $args['attr]
?
Thanks
from the-seo-framework.
Related Issues (20)
- Rename popular filters HOT 3
- Update Gutenberg's permalink store when selecting a primary term.
- Add listeners for default visibility options in quick-edit.
- 5.0 Beta Test. HOT 1
- Add SEO Bar to User list edit
- Set custom namespaces for compatibility files
- Hashtag/pound is removed from theme-color HOT 1
- Typo: "Note: rhe description " on Settings > Homepage > Meta Description HOT 1
- Toggle Sitemap stylesheet header link HOT 1
- Google Tag Manager connection HOT 1
- Sitemap priority setting HOT 1
- Post archive title shows as "No Title - (website name)"
- Site name is not displayed by Google + Schema.org: 'alternateName' is missing HOT 7
- Make archive exclusions work for adjacent post links. HOT 2
- Polylang: Wrong canonical URL for non-default language's homepage HOT 1
- `wp_sitemaps_post_types` vs `the_seo_framework_sitemap_supported_post_types` hook HOT 3
- Add noindex headers to the Core Sitemap
- Add breadcrumb title and hierarchy options HOT 8
- Option to not notify search engines on post update
- Allow setting of custom alternateName(s)
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 the-seo-framework.