WordPress Bild aus der Mediathek via Shortcode einbinden

PHP Snippet > Output als Shortcode

PHP
<?php
$image_id = 298; // Bild-ID

$attr = array(
    'class' => 'css-klassen',
    'id'    => 'element-id',
);

// Output the image with responsive attributes and custom class/id
echo wp_get_attachment_image($image_id, 'full', false, $attr);
?>