• Resolved RafaelDeJongh

    (@rafaeldejongh)


    So I’ve always used the following code snippet to force the default OG:Image and Twitter:Card image:

    add_filter('wpseo_pre_analysis_post_content','mysite_opengraph_content');
    function mysite_opengraph_content($val){return '<img src="https://www.rafaeldejongh.com/wp-content/uploads/2017/08/RafaelDeJongh-Web-Developer-3D-Artist.jpg" alt="Rafa?l De Jongh - Web Developer | 3D Artist"/>' . $val;}

    However this doesn’t seem to work anymore, does anyone know a different way to solve this like it did in the past with above mentioned code?

    It’s a shame the plugin still doesn’t have this feature by default.

    • This topic was modified 7 years, 4 months ago by RafaelDeJongh.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter RafaelDeJongh

    (@rafaeldejongh)

    To clarify, I’m after adding a default image as a first entry in the og:image so there will always be an og:image present (user defined) that’s in the first place next to other og:images that can be found on the page.

    The action that allows an OG image to be added seemed to be the thing I was looking for. But now the only thing I’m wondering if the following code I made up is the proper way to deal with it:

    $default_opengraph = 'https://www.rafaeldejongh.com/…/RafaelDeJongh-Web-Developer…';
    function add_default_opengraph($object){global $default_opengraph; $object->add_image($default_opengraph);}
    add_action('wpseo_add_opengraph_images','add_default_opengraph');
    function default_opengraph(){global $default_opengraph; return $default_opengraph;}
    add_filter('wpseo_twitter_image','default_opengraph');

    As well as this one doesn’t add additional twitter:images but as far as I know there should also only be one for this.

    Any further information on code improvements it’s very much appreciated!

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    We can’t offer support on the custom code (needed to change (core) features of our plugin). Since we don’t want to take the risk that we break your website by suggesting an incorrect or incomplete code, we cannot advise you on how to make such changes. Maybe someone watching these forums can assist you further, but if your topic is inactive for 7 days, we’ll mark it as resolved to keep the overview.

    Thank you for your understanding.

    Thread Starter RafaelDeJongh

    (@rafaeldejongh)

    @mazedulislamkhan

    This is regarding your plugins hooks which are very badly documented. I don’t see why you wouldn’t be able to help me as it is related to the plugin. I require some further insight to which hooks to use to manipulate the things I require.

    If it breaks the website then I’m responsible for using that code and can find my own way to fix it, so you don’t really need to risk anything on that.

    What I do need is someone that can inform me how to actually properly get this code snippet working with the new hooks!

    .

    • This reply was modified 7 years, 4 months ago by jamiefryatt.
    Thread Starter RafaelDeJongh

    (@rafaeldejongh)

    @jamiefryatt

    Why did you remove your post?

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    We’re unable to provide support on custom code. However, you can take a look at our extensive API page to see the available API and implement the most relevant ones that suits best for you.

    Thread Starter RafaelDeJongh

    (@rafaeldejongh)

    @mazedulislamkhan

    That’s the thing, your API’s page is not properly documented, lots of lacking actions and filters, especially the ones I actually require here.

    If it was properly documenten I could perhaps make it myself, but now I need to search so far with hooks that aren’t properly documented that I don’t know where I should start.

    For example you no where define the twitter hooks or explain how they’re used, how am I able to check which hooks I should use for my use case?

    I’ve seen you guys helping people with similar problems in this forum as well, so why aren’t you doing it this time?

    Hi,

    We understand the concern, however we are unable to offer specific actionable advice on how to implement hooks and filters into your custom code. Since we are not familiar with the custom code we are not sure what actions or hooks or filters you may or may not need. We only know we keep a list of them here.

    However, please know our plugin repository is searchable. You may wish to search the repository for the specific code you need. Indeed, we searched for “og:image” and it generated a list of code related to it here and “twitter hooks” here.

    Closed due to inactivity.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Force default OG:Image’ is closed to new replies.