Generating attaachment metadata does not work
-
Hi,
I have some trouble with images uploaded programmatically to my WordPress site. When I am trying to get the attachment metadata, there isn’t any available.
So I tried creating my own function, which checks if
wp_get_attachment_metadata
is empty and then tries to generate it!Unfortunately, my code does nothing. It does not give any errors, what should I do?
My function:
function get_attachment_meta_data_sem($attch_id) { $meta_data = wp_get_attachment_metadata($attch_id); if($meta_data == ''){ $attachment_path = get_attached_file($attch_id); $attach_data = wp_generate_attachment_metadata( $attch_id, $attachment_path); wp_update_attachment_metadata( $attach_id, $attach_data ); return $attach_data; }else{ return wp_get_attachment_metadata($attch_id); } }
But in this example,
$attach_data
stays empty.Thank you in advance!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Generating attaachment metadata does not work’ is closed to new replies.