Skip to content

Commit

Permalink
version 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmereal committed Jun 12, 2024
1 parent 8fc3782 commit 4ce7cdb
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 24 deletions.
22 changes: 22 additions & 0 deletions admin/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ function ogio_customizer_fields( $wp_customize ) {
),
) ) );

$wp_customize->add_setting('ogio_image_source', array(
'default' => 'default',
'transport' => 'refresh',
'type' => 'option',
) );

$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'ogio_image_source', array(
'label' => __('Image Source', 'ogio'),
'description' => __( 'Select the image source for the Open Graph Image. You can use the image set under "Social" tab on your Yoast SEO settings.', 'ogio' ),
'section' => 'ogio_settings',
'settings' => 'ogio_image_source',
'type' => 'radio',
'choices' => array(
'default' => 'Default - use the featured image',
'yoast-fb'=> 'Yoast SEO - Facebook Image',
'yoast-x' => 'Yoast SEO - X Image',
),
'active_callback' => function() use ( $wp_customize ) {
return $wp_customize->get_setting( 'ogio_select_seo_plugin' )->value() == 'yoast';
},
) ) );

$wp_customize->add_setting( 'ogio_plugin_compatibility_notice', array() );
$wp_customize->add_control(new Info_Custom_control($wp_customize, 'ogio_plugin_compatibility_notice', array(
'label' => __('This plugin works automatically along with either Yoast SEO or Rank Math SEO plugin. If you are not using any one of them, you will need to manually set the generated Open Graph Image.', 'ogio'),
Expand Down
20 changes: 15 additions & 5 deletions admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,23 @@ function generate_og_image( $post_id ) {

} else {

if ( get_post_thumbnail_id( $post_id ) ) {
$featured_image = get_post_thumbnail_id( $post_id );
$image_source = get_option( 'ogio_image_source' );

if ( $image_source == 'yoast-fb' || $image_source == 'yoast-x' ) {
if ( $image_source == 'yoast-fb' ) {
$featured_image = get_post_meta( $post_id, '_yoast_wpseo_opengraph-image-id', true ) ?: get_post_thumbnail_id( $post_id );
} elseif ( $image_source == 'yoast-x' ) {
$featured_image = get_post_meta( $post_id, '_yoast_wpseo_twitter-image-id', true ) ?: get_post_thumbnail_id( $post_id );
}
} else {
if ( get_option( 'ogio_fallback_image' ) ) {
$featured_image = get_option( 'ogio_fallback_image' );
if ( get_post_thumbnail_id( $post_id ) ) {
$featured_image = get_post_thumbnail_id( $post_id );
} else {
wp_die( 'Please correctly configure the Open Graph Image Overlay settings.' );
if ( get_option( 'ogio_fallback_image' ) ) {
$featured_image = get_option( 'ogio_fallback_image' );
} else {
wp_die( 'Please correctly configure the Open Graph Image Overlay settings.' );
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions og-image-overlay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Plugin Name: Open Graph Image Overlay
Plugin URI: https://itsmereal.com/plugins/open-graph-image-overlay
Description: Add automated image overlay on top of Open Graph images. This plugin extends the Open Graph features from Yoast SEO or Rank Math plugin.
Version: 1.4
Version: 1.5
Author: Al-Mamun Talukder
Author URI: https://itsmereal.com
Requires at least: 4.3
Tested up to: 6.0.2
Tested up to: 6.5.4
License: GPLv2 or later
Text Domain: ogio
*/
Expand Down
35 changes: 19 additions & 16 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Generate Open Graph images automatically with an image overlay of your choice. Showing off your branding just got a little easier 👌

This plugin currently works alongside with two popular SEO plugins.

1. Yoast SEO
1. Rank Math

Expand All @@ -21,30 +22,32 @@ This plugin currently works alongside with two popular SEO plugins.

## Usage

* Install and activate the plugin. Got to Settings > OG Image Overlay and update the plugin settings.
* Select a fallback image
* Select the overlay image
* Set X and Y value to position the overlay image
* If you are using Yoast or Rank Math for SEO, choose the correct one in the settings otherwise it will not work.

- Install and activate the plugin. Got to Settings > OG Image Overlay and update the plugin settings.
- Select a fallback image
- Select the overlay image
- Set X and Y value to position the overlay image
- If you are using Yoast or Rank Math for SEO, choose the correct one in the settings otherwise it will not work.

## Video Walkthrough

[![Watch the video](https://itsmereal.com/wp-content/uploads/2020/07/ogio-video.png)](https://vimeo.com/437133732)

[ভিডিওটি বাংলায় দেখতে চাইলে এখানে ক্লিক করুন](https://www.youtube.com/watch?v=AmYM-_w-K7I)

## FAQs

* **I am not using Yoast or Rank Math, what can I do?**\
If you are not using one of them but still want to use overlay image on top of your open graph images, you can manually set the link. You can get the generated URL to use from the plugin settings page (look at the right side preview with instructions).
* **Do I need to upload certain sized image?**\
It is best to use 1200px by 630px images as the source. For the overlay it can be any size that fits the source image size.
* **How do I know what to use for X and Y in the plugin settings?**\
X value is for the X axis and Y value is for the Y axis of the final image. You have to carefully measure the width and height and set the correct values. The preview shown on the plugin settings page can be wrong if not used properly (the recommended 1200px by 630px). So, always test your output image first. You can easily check for the generated image url from page source. Here is an example output.\
![Sample Output](https://itsmereal.com/wp-content/uploads/2022/10/ogio-link-preview.png)

* **I already have a different sized featured image dimention for my featured size, how do I change it?**\
You will need to replace your uploaded images if you want to use the recommended 1200 x 630 pixels dimention or a new dimention that you want to use for all your uploads in future. You can replace your current media files with a handy plugin called [Enable Media Replace](https://wordpress.org/plugins/enable-media-replace/).
- **I am not using Yoast or Rank Math, what can I do?**\
If you are not using one of them but still want to use overlay image on top of your open graph images, you can manually set the link. You can get the generated URL to use from the plugin settings page (look at the right side preview with instructions).
- **Do I need to upload certain sized image?**\
It is best to use 1200px by 630px images as the source. For the overlay it can be any size that fits the source image size.
- **Can I use different image source for the Open Graph Image?**\
Since version 1.5, you will be able to use image added to the Socal tab on your Yoast SEO settings under each post.
- **How do I know what to use for X and Y in the plugin settings?**\
X value is for the X axis and Y value is for the Y axis of the final image. You have to carefully measure the width and height and set the correct values. The preview shown on the plugin settings page can be wrong if not used properly (the recommended 1200px by 630px). So, always test your output image first. You can easily check for the generated image url from page source. Here is an example output.\
![Sample Output](https://itsmereal.com/wp-content/uploads/2022/10/ogio-link-preview.png)

- **I already have a different sized featured image dimention for my featured size, how do I change it?**\
You will need to replace your uploaded images if you want to use the recommended 1200 x 630 pixels dimention or a new dimention that you want to use for all your uploads in future. You can replace your current media files with a handy plugin called [Enable Media Replace](https://wordpress.org/plugins/enable-media-replace/).

## License

Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: realblackz
Donate link: https://itsmereal.com
Tags: media
Requires at least: 4.3
Tested up to: 6.0.2
Tested up to: 6.5.4
Stable tag:
Requires PHP: 5.4
License: GPLv2 or later
Expand Down Expand Up @@ -39,6 +39,10 @@ If you are not using one of them but still want to use overlay image on top of y

== Changelog ==

= 1.5 =
* 2024-06-12
* Added option to use Yoast Social Image (Facebook or X) as source image for the open graph image.

= 1.4 =
* 2022-09-29
* Changed plugin image URL structure
Expand Down

0 comments on commit 4ce7cdb

Please sign in to comment.