GithubHelp home page GithubHelp logo

Comments (6)

sybrew avatar sybrew commented on May 29, 2024 2

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.

sybrew avatar sybrew commented on May 29, 2024 1

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.

CHadetz avatar CHadetz commented on May 29, 2024 1

Looks like it works just by copypasting your code. Thank you again!

from the-seo-framework.

sybrew avatar sybrew commented on May 29, 2024

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.

samburgers avatar samburgers commented on May 29, 2024

Thanks for the fast reply, yep that is exactly what i need to do!

from the-seo-framework.

CHadetz avatar CHadetz commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.