• Resolved mattce

    (@mattce)


    Hi,

    I am using this plugin for a few years already, I’ve placed the “Phoenix_Media_Rename::do_rename” function inside a template to rename some images by passing by the attachment id. I don’t know exactly when it stopped working, because I didn’t touch this project for a while, but it was running fine in the past, seems to be caused by one of the plugin updates, but I cannot say which one unfortunately.

    Now it get this error when calling the template:

    Fatal error: Uncaught Error: Call to undefined function wp_generate_attachment_metadata() in xxxx/wp-content/plugins/phoenix-media-rename/classes/class-media-rename.php:684 Stack trace: #0 xxxx/wp-content/themes/xxxx/template-rename-media.php(95): Phoenix_Media_Rename::do_rename() #1 xxxx/wp-includes/template-loader.php(106): include('…') #2 xxxx/wp-blog-header.php(19): require_once('…') #3 xxxx/index.php(17): require('…') #4 {main} thrown in xxxx/wp-content/plugins/phoenix-media-rename/classes/class-media-rename.php on line 684

    Any idea what has changed? wp_generate_attachment_metadata() seems still to exist, not sure why it’s claiming that it’s undefined.


    Thanks a lot!

    • This topic was modified 2 months, 2 weeks ago by mattce.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author crossi72

    (@crossi72)

    Hi @mattce,
    It is strange, because wp_generate_attachment_metadata is a WordPress’s core funcition, I’ll try to replicate this issue on my development server.

    If you are calling the do_rename methon on the frontend, there could be a problem because wp_generate_attachment_metadata could not be loaded, you can try this kind of solution:

    if ( ! function_exists( 'wp_generate_attachment_metadata' ) ) {
    require_once ABSPATH . 'wp-admin/includes/image.php';
    }

    Let me know if you need more informations
    C

    Thread Starter mattce

    (@mattce)

    You were totally right, by adding your provided snippet to my page template, it started to work again.

    Thanks a lot!
    And thanks for your plugin in general, it’s really helpful.

    Plugin Author crossi72

    (@crossi72)

    It has been a pleasure ??

    C.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.