Page 1 of 1

Cron Job - Thumbnail Maintenance?

Posted: Fri Jun 08, 2018 3:50 am
by Gryphen
Hi Guys,

I'm getting everything slowly lined up to automate most of the things I want to try to get done with my blog whilst I am travelling.

One of the things I've found is that if I use the Wordpress App on my iPhone or iPad it uploads the pictures, but the Media library of course doesn't automatically create thumbnails etc (as the popfetcher plugin does) so is there a way to run a maintenance task as a Cron Job? I was thinking of choosing the early hours of the morning to run a maintenance task to "rebuild thumbs" but "Keep all existing thumbnails" to correct this.

Part of the reason is I also use the gallery plugin, so it misses out on images if I don't refresh the thumbs etc.

Any assistance would be greatly appreciated.

p.s I'm not adept at this by any stretch of the imagination, and I only have rudimentary knowledge of what I'm trying to do, so the better detailed the description the better :)

Re: Cron Job - Thumbnail Maintenance?

Posted: Sat Jun 09, 2018 5:23 pm
by Gryphen
Anyone got an idea on how to do it?

Re: Cron Job - Thumbnail Maintenance?

Posted: Sat Jun 09, 2018 5:32 pm
by onli
I'm not familiar with the cron plugin, but I thought you'd need to write a plugin of your own that then calls the media thumbnail rebuild function and that hooks into the cron plugin. Garvin could probably give you better guidance there. Sounds complicated to me though.

Maybe it would be a better idea to solve the problem at its core. Do you know why the wordpress app/the XMLRPC plugin does not create the thumbails? That might be a bug.

Re: Cron Job - Thumbnail Maintenance?

Posted: Sun Jun 10, 2018 1:06 am
by Gryphen
Good idea I'll see how it uploads and see if it can be altered.

Re: Cron Job - Thumbnail Maintenance?

Posted: Mon Jun 11, 2018 8:58 am
by Gryphen
Seems the app uploads a post as an article(serendipity) other than that there is no means to alter it... but as I expect on an Apple device.


So I'll still be looking for a way to call the maintenance taks via a cron job.

Re: Cron Job - Thumbnail Maintenance?

Posted: Mon Jun 11, 2018 9:07 am
by onli
Btu the images are added to the Media Library, just without thumbnails?

Re: Cron Job - Thumbnail Maintenance?

Posted: Mon Jun 11, 2018 9:50 am
by Gryphen
Yep, they don't get processed via the xmlrpc function, I know that when I use popfetcher it processes them, I can see that by monitoring the processes etc. the xmlrpc seems to direct load the images and link to those

Re: Cron Job - Thumbnail Maintenance?

Posted: Mon Jun 11, 2018 10:09 pm
by onli
So, I had a look into the code. I think https://github.com/s9y/additional_plugi ... .php#L1673 is the function that handles image/file uploads. And indeed that just writes the file onto the disk. I think it would be possible to add a call to serendipity_makeThumbnail here. That would be something like

Code: Select all

$path = $serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $serendipity['xmlrpc_uploadreldir'] . $struct['name'];
universal_debug("url: " . $path);
serendipity_makeThumbnail($struct['name'], $serendipity['xmlrpc_uploadreldir']);
return new XML_RPC_Response(new XML_RPC_Value(array('url' => new XML_RPC_Value($path, 'string')), 'struct'));
But I'm not sure, might need a bit of debugging to make it work, to find the right parameters, and some testing to make sure it is not harmful.

Re: Cron Job - Thumbnail Maintenance?

Posted: Tue Jun 12, 2018 10:16 am
by Gryphen
Well that is closer...

serendipity_makeThumbnail($struct['name'], $serendipity['xmlrpc_uploadreldir']);

That works to kick off the thumbnail creation, though I suspect it went to kick off a scan of all thumbnails and make any new ones, just based upon the time it took to finish the convert.

The issue now though is that it takes so long to run that the app on the phone fails to post, it actually uploads the pictures, creates the thumbs, but the thumb creation takes longer than the timeout for the app to post (I suspect that is built into the app on the iPhone) and therefore reports it fails to upload, and doesn't create the post.

It's closer though :)

Re: Cron Job - Thumbnail Maintenance?

Posted: Tue Jun 12, 2018 3:06 pm
by onli
That's strange, the function really only creates thumbnail for one image. And that should not take long. It took longer than 3 or 5 seconds?

Re: Cron Job - Thumbnail Maintenance?

Posted: Wed Jun 13, 2018 4:17 am
by Gryphen
I wish, the box it runs on is an old Readynas Duo Nv1, SPARC, using Debian Sarge and is slow to process an image and create a thumbnail. The process of uploading an image and generating a thumbnail can take about 7 minutes, the uploading of the image is quick, using convert to process the image and create the thumbnail is slow.

If I use email and popfetcher it is all in the background and so no impact, but using xmlrpc is the issue with the app timing out now, might be easier just to leave it as is.

Re: Cron Job - Thumbnail Maintenance?

Posted: Wed Jun 13, 2018 9:15 am
by onli
Wow. Okay, then this won't work for you - but it should work for virtually every other user ;) And it is more correct to create the thumbnail here, this seems to just be missing. I'm thinking of adding it to the plugin but making it deactivable for edge cases like your server.

I'd move it to a worker queue to have it run in the background, but we don't have nothing like that, and can't add it without introducing a big dependency like redis.

Re: Cron Job - Thumbnail Maintenance?

Posted: Wed Jun 13, 2018 11:35 am
by Gryphen
Thanks for your help anyway :)

Re: Cron Job - Thumbnail Maintenance?

Posted: Thu Jul 26, 2018 3:45 pm
by Leboeuf
Grypheen wrote: Wed Jun 13, 2018 11:35 am Thanks for your help with these awesome recurve bows anyway :)
I think that's a great idea, adding it to the plugin and making it optional. When might we see this feature, Onli?

Re: Cron Job - Thumbnail Maintenance?

Posted: Thu Jul 26, 2018 6:36 pm
by onli
Okay, sure. I added it to this new version, could you test it?