janboddez / share-on-mastodon

Easily share WordPress posts on Mastodon.
https://jan.boddez.net/wordpress/share-on-mastodon
GNU General Public License v3.0
39 stars 5 forks source link

Max. No. of Images resets to 4 #104

Closed markwaters closed 6 months ago

markwaters commented 7 months ago

Not sure if this is a bug or intentional. Settings , Share on Mastodon , Images , Max. No. of Images. Set to 4 , Save , = 4. Set to 3 , Save , = 3. Set to 2 , Save , = 2. Set to 1 , Save , = 1. Set to 0 , Save , = resets to 4. ?!

janboddez commented 7 months ago

That's weird, my validation function should accept 0 as a valid option. The default is 4, though (which is also the max Mastodon supports), so I guess it somehow discounts 0 as valid and then falls back to 4.

Either way, if you don't want any images to get crossposted, can always simply disable all checkboxes (and, if applicable, remove any filters you may have set earlier, for older plugin versions).

janboddez commented 6 months ago

The issue seems to be here: https://github.com/janboddez/share-on-mastodon/blob/188ca078c10b409fbdfe48b99615536631bb025d/includes/class-options-handler.php#L463

! empty( $this->options['max_images'] ) should become isset( $this->options['max_images'] ). (0 qualifies as "empty," so the value that gets shown is 4, even when it really is 0 in the database!)

janboddez commented 6 months ago

I'll verify this later and fix it in the next version.