Support » Plugin: OG » og:image:secure_url

  • Resolved mociofiletto

    (@mociofiletto)


    Hi, I am testing this plugin. It seems not to write og:image:secure_url on https pages. I am not sure, but this seems to be required by some applications as WhatsApp.
    Is there a way to add this meta property?
    Thanks

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

Viewing 11 replies - 1 through 11 (of 11 total)
  • I have looked at your code and I think this patch could do the stuff:

    --- ./plugins/og/vendor/iworks/opengraph.php_orig	2020-05-30 13:35:04.271922354 +0200
    +++ ./plugins/og/vendor/iworks/opengraph.php	2020-05-30 21:14:05.548202929 +0200
    @@ -477,6 +477,26 @@
     		 */
     		$og = apply_filters( 'og_array', $og );
     		/**
    +		 * Add OG image secure_url
    +		 *
    +		 * @since 2.7.7
    +		 *
    +		 * @param array $og Array of all OG tags.
    +		 */
    +		if ( array_key_exists( 'image', $og['og'] ) ) {
    +			if ( is_array( $og['og']['image'] ) ) {
    +				$img_url = $og['og']['image'][0];
    +			} else {
    +				$img_url = $og['og']['image'];
    +			}
    +			if ( 'https' === substr( $img_url, 0, 5 ) ) {
    +				if ( ! is_array( $og['og']['image'] ) ) {
    +					$og['og']['image'] = str_split( $og['og']['image'], strlen( $og['og']['image'] ) );
    +				}
    +				$og['og']['image']['secure_url'] = $img_url;
    +			}
    +		}
    +		/**
     		 * print
     		 */
     		$this->echo_array( $og );
    Plugin Author Marcin Pietrzak

    (@iworks)

    hi @mociofiletto

    Could you update to 2.7.7 and confirm (or denied) is all ok?

    Marcin

    No, it’s not. I just updated and the site went down. I add to disable now. now I am looking ad your code.

    on this domain 2.7.7 gives fatal error: https://www.vivatacademia.org/
    on this domain 2.7.7 doesn’t output og:image:secure_url https://bertocchi28.ddns.net/

    • This reply was modified 1 month, 1 week ago by mociofiletto.

    on second domain it outputs og:image:secure_url in article page, not in home page where no featured image is set.

    I set WP_DEBUG and WP_DEBUG_LOG on first site. The problem that crashes it is in line 178

    Error: [] operator not supported for strings in /home/_user_/public_html/wp-content/plugins/og/vendor/iworks/opengraph.php

    I am investigating it because, in my understanding, this issue should not be present on PHP > 7.1.
    On first domain the error arises both with PHP 7.3.13 and with PHP 7.4.1

    I cannot reproduce this error on the other server (with both PHP 7.3.18 and 7.4.6)

    Plugin Author Marcin Pietrzak

    (@iworks)

    hi @mociofiletto

    Thx, noted. Please update into 2.7.8 and re-check issue with array/string [].

    Sorry for it.

    Marcin

    Hi @iworks I updated to 2.7.8 and the main issue with array/string [] is fixed, thanks.
    However I think there is a problem, still.
    In this page: https://www.vivatacademia.org/ you can see that these meta property are in output:
    og:image:width
    og:image:height
    og:image:alt
    but there is no og:image meta, or og:image:secure_url

    while on this page https://bertocchi28.ddns.net/
    I have og:image (pointing to favicon), but not og:image:secure_url

    It seems the problem is with page not “singular” or with pages without featured image where the plugins outputs just favicon into og:image and outputs no og:image:secure_url (look here https://www.vivatacademia.org/chi-siamo/lo-statuto-dellassociazione/). I think it is better to output the “Fallback Image” if theme supports it.

    For not “singular” page, I think that this is due to the secure_url loop being into the if ( is_singular() ) { statement (maybe it is better to loop the array inside function echo_array( $og, $parent = array() ).

    However, thanks for your work.

    Plugin Author Marcin Pietrzak

    (@iworks)

    @mociofiletto

    On not “singular” pages, pointing to site favicon is intentional action To avoid grabbing some random images from an “archive” page.

    Size,alt without url – is a cache issue – I’m working on it now.

    M

    Plugin Author Marcin Pietrzak

    (@iworks)

    Ok, please re-test with 2.7.9
    I include plugin version in cache key, to avoid lack of changes between versions.

    M

    Thanks @iworks it seems to work as expected now.
    Really, thanks

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.