Title: Force default OG:Image
Last modified: October 19, 2017

---

# Force default OG:Image

 *  Resolved [RafaelDeJongh](https://wordpress.org/support/users/rafaeldejongh/)
 * (@rafaeldejongh)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/)
 * 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 8 years, 6 months ago by [RafaelDeJongh](https://wordpress.org/support/users/rafaeldejongh/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fforce-default-ogimage%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Thread Starter [RafaelDeJongh](https://wordpress.org/support/users/rafaeldejongh/)
 * (@rafaeldejongh)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9603423)
 * 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!
 *  [Md Mazedul Islam Khan](https://wordpress.org/support/users/mazedulislamkhan/)
 * (@mazedulislamkhan)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9604667)
 * 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](https://wordpress.org/support/users/rafaeldejongh/)
 * (@rafaeldejongh)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9605033)
 * [@mazedulislamkhan](https://wordpress.org/support/users/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!
 *  [jamiefryatt](https://wordpress.org/support/users/jamiefryatt/)
 * (@jamiefryatt)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9605656)
 * .
    -  This reply was modified 8 years, 6 months ago by [jamiefryatt](https://wordpress.org/support/users/jamiefryatt/).
 *  Thread Starter [RafaelDeJongh](https://wordpress.org/support/users/rafaeldejongh/)
 * (@rafaeldejongh)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9605774)
 * [@jamiefryatt](https://wordpress.org/support/users/jamiefryatt/)
 * Why did you remove your post?
 *  [Md Mazedul Islam Khan](https://wordpress.org/support/users/mazedulislamkhan/)
 * (@mazedulislamkhan)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9607163)
 * We’re unable to provide support on custom code. However, you can take a look 
   at our extensive [API page](https://yoast.com/wordpress/plugins/seo/api/) to 
   see the available API and implement the most relevant ones that suits best for
   you.
    -  This reply was modified 8 years, 6 months ago by [Md Mazedul Islam Khan](https://wordpress.org/support/users/mazedulislamkhan/).
 *  Thread Starter [RafaelDeJongh](https://wordpress.org/support/users/rafaeldejongh/)
 * (@rafaeldejongh)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9607753)
 * [@mazedulislamkhan](https://wordpress.org/support/users/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?
 *  [Pcosta88](https://wordpress.org/support/users/pcosta88/)
 * (@pcosta88)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9612683)
 * 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](https://yoast.com/wordpress/plugins/seo/api/).
 * 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](https://github.com/Yoast/wordpress-seo/search?utf8=%E2%9C%93&q=og%3Aimage&type=)
   and “twitter hooks” [here](https://github.com/Yoast/wordpress-seo/search?utf8=%E2%9C%93&q=twitter+hooks&type=).
 *  [Jerlyn](https://wordpress.org/support/users/jerparx/)
 * (@jerparx)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9637870)
 * Closed due to inactivity.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Force default OG:Image’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [image](https://wordpress.org/support/topic-tag/image/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)
 * [twitter](https://wordpress.org/support/topic-tag/twitter/)

 * 9 replies
 * 5 participants
 * Last reply from: [Jerlyn](https://wordpress.org/support/users/jerparx/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/force-default-ogimage/#post-9637870)
 * Status: resolved