• Resolved Xaver

    (@xaverb)


    Is there a way to compress an image by attachemnt_id like so:

    $result = tiny_compress( $attachment_id );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author TinyPNG

    (@tinypng)

    Hi Xaver,

    Thanks for writing!

    No, at the moment there is not a simple method you can call with only the attachment id to compress images. Interestingly, another user just recently opened the same feature request on the Github repository: https://github.com/tinify/wordpress-plugin/issues/21

    As you can also read there, you could for the time being use the compress() function of Tiny_Image. In order to call that, you first need to create a Tiny_Image instance by passing along a few arguments. You can find examples on how it’s being used within the plugin in class-tiny-plugin.php.

    I hope that helps you!

    Thread Starter Xaver

    (@xaverb)

    Thanks! I’m looking forward to see this added.

    Create plugin/service!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Compress image via PHP’ is closed to new replies.