Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

wp_get_original_image_url

Function Description:

Retrieves the URL to an original attachment image.

Function Examples:

⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Get the original image URL of a specific attachment
$attachment_id = 123;
$original_image_url = wp_get_original_image_url($attachment_id);
echo $original_image_url;
// Example 2: Check if the original image URL exists before displaying it
$attachment_id = 456;
$original_image_url = wp_get_original_image_url($attachment_id);

if ($original_image_url) {
    echo $original_image_url;
} else {
    echo "Original image URL not found.";
}
// Example 3: Use the original image URL as a fallback if a custom size is not available
$attachment_id = 789;
$custom_image_size = 'thumbnail';
$custom_image_url = wp_get_attachment_image_url($attachment_id, $custom_image_size);

if (!$custom_image_url) {
    $original_image_url = wp_get_original_image_url($attachment_id);
    echo $original_image_url;
} else {
    echo $custom_image_url;
}