Comments (10)
Hmm, I was just able to crosspost a featured image just fine, (even) from the WP app. (Force-enabled crossposting by adding add_filter( 'share_on_mastodon_enabled', '__return_true', 999 );
to a must-use plugin, but you got that part right or it wouldn't work at all ... [That prio number is pretty random, btw. Just didn't wanna take any risks.] Did not touch any of the other filters.)
Is your featured image correctly set, on the post itself?
Any idea what Mastodon version your instance is on? (I'm still on 3.2.2, I believe the latest one is 3.3.0.) One thing that comes to mind is the media endpoint I'm using was going to deprecated ... On 3.3.0 now, still works, I'm afraid: https://geekcompass.com/@ochtendgrijs/105510788586078078.
Another is that the image is too large or the request times out, although I set that to 15 seconds.
Would you mind enabling debug logging, by adding something like this to wp-config.php
?
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
I'm pretty much writing the entire error/response to the debug log, but only when logging is enabled.
Then, if something isn't going as planned, it should show in the log.
from share-on-mastodon.
Yeah, I'll do some more testing tonight with debugging turned on. I'm wondering if for new posts there is a timing/order issue since the image may not actually but uploaded to the site yet when the post is uploaded/published.
from share-on-mastodon.
Just curious: any update on this?
I mostly use a Micropub app (which is somewhat similar), rather than the official WP app, and because it doesn't do Featured Images per se, I sort of am delaying crossposting till I've "fixed" that (force-set a Featured Image, in a way, but after the post's already published) later on in WordPress's sequence. So that would be kind of similar.
I guess what I'm saying is, you could also not use share_on_mastodon_enabled
, but rather set the underlying post meta field after crossposting would normally take place, and only then "trigger" crossposting (or, perhaps, schedule it a couple minutes into the future).
Just a quick thought:
// This would run _after_ crossposting to Mastodon would normally take place.
add_action( 'publish_post', function( $post_id, $post ) {
if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
// Do nothing.
return;
}
// Bluntly enable sharing to Mastodon for each and every post.
update_post_meta( $post_id, '_share_on_mastodon', '1' );
// Quick and dirty way to re-trigger Share on Mastodon's `Post_Handler::toot()` method.
// do_action( 'transition_post_status', 'publish', 'publish', $post ); // Still too soon?
wp_schedule_single_event( time() + 60, 'my_custom_event', array( $post ) ); // Or something like this.
}, 10, 2 );
add_action( 'my_custom_event', function( $post ) {
// Quick and dirty way to re-trigger Share on Mastodon's `Post_Handler::toot()` method.
do_action( 'transition_post_status', 'publish', 'publish', $post );
} );
Of course, publish_post
works only for, well, posts. But there are ways around that as well. (Was hoping to avoid endless loops here by not reusing transition_post_status
.)
from share-on-mastodon.
I ran into the same issue. I'm posting via xmlrpc, and I'm using a plugin to always set the first image as the featured image (and I've set Share on Mastodon to include the featured image, and no attached images). But perhaps that plugin is being run too late, so there's no featured image when Share on Mastodon is being triggered?
I wonder whether an alternate take on this would simplify things: I want the first image in the post to be included, so I could instead use share_on_mastodon_attached_images true -- if I could control the number of attached images to include. That's currently hardcoded at 4 (in post_to_mastodon). If that wasn't hardcoded, I could just change the number of images to 1, and things would presumably work as I want them to...
from share-on-mastodon.
But perhaps that plugin is being run too late, so there's no featured image when Share on Mastodon is being triggered?
I've been trying to replicate this behavior, unsuccessfully.
The latest version has an option for delayed posting. What happens when you use that? Set it to, e.g., 300 seconds or so?
You could even post a test post through XML-RPC, and then check in WP Admin (without saving anything, as that would trigger syndication) if the featured image is really there. If so, it should go through okay once the cron event is triggered.
Would that be something you're willing to give a try?
from share-on-mastodon.
Sure, I can give delayed posting a try. I had a peek at the documentation, but didn't see any mention of "delay" there -- what's the incantation to use?
from share-on-mastodon.
There should be a field on the settings page. Maybe try setting it to 300 seconds (or 120 or something, but, say, more than a minute)?
from share-on-mastodon.
Ah, right. I've now updated the setting and will be testing later today and get back to you on the results.
from share-on-mastodon.
I've now tried it, and it seems to work perfectly. I used a 30 second delay, but I can probably make that shorter.
from share-on-mastodon.
Ah, cool! Yeah, either it's something using a later hook than the one I use to trigger syndication, or some background process that hasn't yet finished. Glad it works this way. I should update the documentation now.
from share-on-mastodon.
Related Issues (20)
- Article title box not forming from link by default HOT 2
- Alt Text on Images HOT 2
- Missed alt text on 1/2 images HOT 7
- Provide status on post to Mastodon HOT 6
- Emoji in post titles (maybe bug? maybe my fault? maybe a feature request?) HOT 3
- Less strict URL input field? HOT 10
- No reactivation after upgrade HOT 3
- alt text not transferring HOT 49
- Error status HOT 2
- Filter function to format your toots better HOT 1
- Customizing the post/toot HOT 14
- Custom Post Type posts again when updated HOT 4
- Revoke client ID and secret? HOT 1
- "Something went wrong contacting your Mastodon instance" HOT 13
- Syndication links HOT 2
- Requires manual update to toot HOT 3
- Store/display API client errors HOT 3
- register_post_meta should be called inside rest_api_init callback
- Featured image is posted twice to Mastodon HOT 7
- Error_log full of entries from the plugin HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from share-on-mastodon.