Internetbureau Clearsite
Forum Replies Created
-
We will plan a permanent solution for this in version 1.1.0, and I will create a bugfix release 1.0.20 for this soon.
Edit: 1.0.20 should be available soon
Implement a filter like this:
add_filter('bsi_image_url', function($url) { return add_query_arg('_', time(), $url); });
to add a timestamp to the url.
This will change the OG:Image URL every second. For version 1.1.0 we’re planning the option to add the actual timestamp of last change.
- This reply was modified 2 years, 11 months ago by Internetbureau Clearsite.
I’m running Sucuri myself and I have no indications of any problem, but we take things like this very seriously.
Please send any and all information you can find on this to [email protected].
Thank you!
^RP
About the Font:
This is explained in the FAQ; you will need to download a compatible font and upload it. Please let us know if this solves the problem.
About the logo; please share a screenshot, and post the output of the debug information you get when you add ?debug=BSI to the social-image url.
Thank you
Hello @marashmallow
Yes, BSI is supposed to work with any post type.
Can you go to a problem post and check if the social-image.jpg endpoint is advertised in the HTML (as in; the og:image meta is in the output)
Then, please check the output given by the social-image.jpg url appended with ?debug=BSI
If this url also redirects you, please try ?bsi_img=1 instead of /social-image.jpg/ and see what that does.
so the image should be working on /some-post-url/?bsi_img=1
and the debug output should be visible on /some-post-url/?bsi_img=1&debug=BSIif it is in the HTML output, but does not work, but the ?bsi_img=1 does work, then simply re-saving the permalink settings should fix it.
Otherwise I am very interested in reading the debug output.When you say it’s cleared out after post edit, does that mean bsi_image_cache_built simply runs again and overwrites the old one
Effectively; yes.
The cache is cleared, after which upon the next call the the image-url, the new image is built, and then the actionbsi_image_cache_built
is triggered.
So there must be a http call to the image-url to build the image.I guess that could be a problem, so you could prime the cache on a post_save, if you need to.
maybe something like
add_action('save_post', function($post_id) { // cache is cleared on this action // so bind the shutdown to be "last" add_action('shutdown', function() use ($post_id) { $link = get_permalink($post_id) . 'social-image.jpg/'; // quick and dirty // do something with link here so it points to the "internal" url // which, I would assume, is available for the WordPress install wp_remote_get($link, [ 'blocking' => false ]); }); });
This all hinges on the idea that WordPress _can_ make web-calls to itself.
If not, you would need to do a whole lot more to build the image…I will register a feature request for the option to prime the cache after clearing. Don’t know how feasible this is, but it is worth investigating …
Will let you know if I’m successful, if of interest.
Would very much appreciate it!, thank you ??
^RP
Ideally (but this is based on my limited understanding of your set-up) you would want the social image cached in the CDN or in S3.
There is an action fired after building the image,
do_action('bsi_image_cache_built', $cache_file);
so with
add_action('bsi_image_cache_built', function($cache_file) { //... some code here }
you could upload the cached image to the CDN/S3.
Then you would need to rewrite the urls ending in /social-image.jpg/ to that uploaded file somehow…
Trying to do this all in my head without knowing anything about the software is a challenge, so I hope I’m making sense here …
In any case, the /social-image.jpg url on the WordPress side is a virtual image url, the image itself is built on first call and cached (cleared out when post is edited) but that cache is not directly accessible over the web.
This is indeed outside the scope of our plugin, but let me think about this for a minute, perhaps I can help, although “off the record” ??
What would you need to get this working?
How do you currently serve images on your website?Hi @tomgreeen
first off; thank you ??
then; You can get the URL for the image in two ways;
Option 1; you can just add /social-image.jpg/ to the URL.
Although technically this name (social-image) and extension (jpg) could change, we probably will not ??
Option 2; usePlugin::get_og_image_url($post_id);
You will need to “use” the class; on top of the php file (but below any namespace declaration, if applicable) add
use Clearsite\Plugins\OGImage\Plugin;
Both options, however, create an image url for a post regardless of the enabled-status. So even if there is no image configured, or has been disabled using the post-meta settings, the URL is still the same.
To know if a post actually has a properly configured social image, you can use
Plugin::go_for_id($post_id);
So in total;
<?php // on top of the file (but below any namespace declaration, if applicable) use Clearsite\Plugins\OGImage\Plugin; // your code here if (Plugin::go_for_id($post_id)) { $image_url = Plugin::get_og_image_url($post_id); // do something with the image url here. }
if there is another class named Plugin in the code, you can alias the class like this;
<?php // on top of the file (but below any namespace declaration, if applicable) use Clearsite\Plugins\OGImage\Plugin as BSI; // your code here if (BSI::go_for_id($post_id)) { $image_url = BSI::get_og_image_url($post_id); // do something with the image url here. }
Please realise that while we will always do our best to keep new versions of the plugin backward compatible, we cannot 100% guarantee these function calls will not change in the future.
For example; we are working on compatibility with categories and tags, which probably will change the method signatures to something like
Plugin::go_for_id($object_id, $object_type, $base_type) {};
Plugin::get_og_image_url($object_id, $object_type, $base_type) {};
So keep an eye on the release notes and check before updating.
Hope this helps, please let us know if it does not, or also if it does ??
^RP
At this time, categories (and tags) are not supported and it seems there is a bug that causes the social-image to be advertised on categories, which we need to address first.
Adding meta boxes to categories is not as straight-forward as with posts; it is on the roadmap, but it might take a few versions before it is implemented.
Thank you for your comments ??
^RP
You are absolutely right, Jan. And it really was a last-resort type of situation.
It will not happen again. The plugin should now have more than enough logging to allow debugging without us doing the debugging ourselves ??
We try hard to help everyone but we must accept that it is not always possible.
We’ve put the your suggestion on our roadmap for 2022. We’ll be closing this issue.
Thanks again for the suggestion, Clearsite
Thanks for the five start review!
Oh, I see now it is behind a “basic auth”…
You could try something like this;
<?php add_filter('http_request_args', function($passed_args, $url) { $my_host = parse_url(get_bloginfo('url'), PHP_URL_HOST); if (false !== strpos($url, '://'. $my_host)) { if (empty($passed_args['headers'])) $passed_args['headers'] = []; $passed_args['headers']['Authorization'] = 'Basic '. base64_encode('username:password'); } return $passed_args; }, 10, 2);
of course, use the correct username and password ??
this should make the requests use the authentication (but only when requesting urls on your own website, of course)*) this should never be used nor be needed on a live website!
this is a nice clue:
Text: no text detected in meta-data, getting text from page;
Text: No text found, using default;I think it has to do with your website being password protected.
Can you tell me which plugin you are using for that? we’ll try to replicate the problem.^RP
Hi there danielo83,
Thanks for trying out our plugin. By default it should add the title of a page on the Open Graph image. Please let me know if this is not the case on your installation. And maybe provide us with an url of a page where this doesn’t seem to work?
Regards,
Clearsite- This reply was modified 3 years ago by Internetbureau Clearsite. Reason: typo