<?php
$term_id = get_queried_object_id();
$attachment_id = get_term_meta($term_id, 'url-dosya', true);
$image_data = wp_get_attachment_metadata($attachment_id);
if ($attachment_id && is_array($image_data)) {
$image_url = wp_get_attachment_image_src($attachment_id, 'full')[0];
$mime_type = isset($image_data['sizes']['medium']['mime-type']) ? $image_data['sizes']['medium']['mime-type'] : '';
$width = isset($image_data['width']) ? $image_data['width'] : '';
$height = isset($image_data['height']) ? $image_data['height'] : '';
echo '<meta property="og:image" content="' . esc_url($image_url) . '" />' . "n";
echo '<meta property="og:image:type" content="' . esc_attr($mime_type) . '" />' . "n";
echo '<meta property="og:image:width" content="' . esc_attr($width) . '" />' . "n";
echo '<meta property="og:image:height" content="' . esc_attr($height) . '" />
' . "n";
}
?>