Skip to content

Instantly share code, notes, and snippets.

@magnificode
Last active August 29, 2015 14:13

Revisions

  1. magnificode renamed this gist Jan 21, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. magnificode created this gist Jan 21, 2015.
    11 changes: 11 additions & 0 deletions Attachment Detector
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <?php
    $ctaLink = get_field('static_hero_cta_button_link');
    if (false !== strpos($ctaLink,'attachment_id')) {
    $url = $ctaLink;
    $url_parsed = parse_url($url);
    parse_str($url_parsed['query'], $url_parts);
    $attachmentID = $url_parts['attachment_id']; // attachment ID
    $attachmentSrc = wp_get_attachment_url( $attachmentID ); // returns an array
    $ctaLink = $attachmentSrc;
    }
    ?>