wp_generate_attachment_metadata() doesn’t generate files
-
I am having a hard time writing my own function to regenerate the thumbnail and all intermediate sizes for already uploaded images. For debugging purposes I am setting $img to a pre-existing attachment ID
$img = 303; $meta = wp_get_attachment_metadata( $img ); print("<pre>".print_r($meta,true)."</pre>"); $fullsizepath = wp_get_attachment_url($img); print( $fullsizepath ); $newMeta = wp_generate_attachment_metadata( $img, $fullsizepath ); wp_update_attachment_metadata( $img, $newMeta ); print("<pre>".print_r($newMeta,true)."</pre>");
The first print function lists the correct pre-existing metadata with all sizes and image_meta. Printing $fullsizepath gives the correct full path. When adding the wp_generate_attachment_metadata() function it takes an extra second to execute which I guess it actually reads the file from disk. But the last print() returns only a minimal metadata array without any size elements or image_meta:
Array ( [width] => 2994 [height] => 1952 [file] => https://localhost/v4.ch3.gr/file/ch3_077-37.jpg [sizes] => Array ( ) )
Am I missing something to make this work?
thank you
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘wp_generate_attachment_metadata() doesn’t generate files’ is closed to new replies.