I found that my PHP script throws an 500 (Internal Server Error) at the line which wp_generate_attachment_metadata
function is used:
$attach_data = wp_generate_attachment_metadata( $attach_id, $fullpathfilename );
I can exit and take an output before this line but not after that.
I checked the inputs too:
Array
(
[attach_id] => 101362
[fullpathfilename] => /home/appleapp/USER/wp-content/uploads/2014/05/Beat-the-Boss-2-17+945428.png
)
Any help is really appreciated.
I found that my PHP script throws an 500 (Internal Server Error) at the line which wp_generate_attachment_metadata
function is used:
$attach_data = wp_generate_attachment_metadata( $attach_id, $fullpathfilename );
I can exit and take an output before this line but not after that.
I checked the inputs too:
Array
(
[attach_id] => 101362
[fullpathfilename] => /home/appleapp/USER/wp-content/uploads/2014/05/Beat-the-Boss-2-17+945428.png
)
Any help is really appreciated.
Share Improve this question asked May 3, 2014 at 6:54 revorevo 6475 silver badges19 bronze badges 2- Have you check this [wordpress/support/topic/… ? – Wit Wikky Commented May 3, 2014 at 7:04
- @Rorschach yes, differs from mine. – revo Commented May 3, 2014 at 7:06
2 Answers
Reset to default 1You might need to require once this file:
wp-admin/includes/image.php
wp_generate_attachment_metadata()
should be used in conjunction with wp_update_attachment_metadata()
. So your code should look something like this. (quote from the codex).
To generate attachment metadata for attachment with parent post ID 37:
<?php $attach_id = wp_insert_attachment( $attachment, $filename, 37 ); $attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $attach_data ); ?>