Forum Replies Created

Viewing 1 replies (of 1 total)
  • I solved this by using some regex in my template to detect if the output was a full image tag or just a url like so:

    if( get_post_meta($post->ID, 'images')):
    $images = get_post_meta($post->ID, 'images'); 
    
    foreach($images as $image):
    if(strpos($image, "<img") !== FALSE):
      preg_match('/src=[\"\']([^\"\']+)/i', $image, $matches);
      $imageurl = $matches[1];
    else:
      $imageurl = $image;
    endif;

    You can then use the imageurl variable wherever you need the source. This code will let someone just paste in the url or use the media library to insert a full image.

Viewing 1 replies (of 1 total)