Custom Fields
Re-Envisioned
Support General Custom Field Generate URL Screenshot

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 4 months, 2 weeks ago.

  • Creator
    Topic
  • #12566

    @mindspark
    Participant

    Anh – I found this code snippet and wondered if this could be modified to work with MB? Turns out that there is a third-party ACF addon that does the same thing…

    add_shortcode('ss_screenshot', 'ss_screenshot_shortcode');
     function ss_screenshot_shortcode($atts){
      $width = intval($atts['width']);
      $width = (100 <= $width && $width <= 300) ? $width : 200;
      $site = trim($atts['site']);
    
    if ($site != ''){
     $query_url =  'http://s.wordpress.com/mshots/v1/' . urlencode($site) . '?w=' . $width;
      $image_tag = '<img alt="' . $site . '" width="' . $width . '" src="' . $query_url . '" />';
     echo '<a href="' . $site . '">' . $image_tag . '</a>'; 
    }else{
    
    echo 'Bad screenshot URL!';
    }
    }

    My guess is I would first have to create a special field type for this to work, so I would appreciate help with that too if this is possible.

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #12569

    Anh Tran
    Keymaster

    Hi Neil,

    This snippet creates a shortcode to include the screenshot of a site. It works anywhere, with any plugin. What do you want to do with that?

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.