Shortcode for a Series of Elevating Image Files, Excluding a Range?

You can try the following code snippet:

/**
 * Shortcode for a series of elevating image files, excluding a range
 *
 * @link http://wordpress.stackexchange.com/a/151408/26350
 */

add_shortcode( 'episode', 'episode_shortcode' );

function episode_shortcode( $atts = array(), $content="" )
{
    //-----------------------
    // Settings:
    //
    $path="/path/to/files";
    $ext="jpg";
    //-----------------------

    // Shortcode input:
    $atts = shortcode_atts(
        array( 'num' => 0, 'title' => '', 'images' => '' ), 
        $atts, 
        'episode_shortcode' 
    );

    // Sanitize input:
    $images = esc_attr( $atts['images'] );
    $title  = esc_attr( $atts['title'] );
    $num    = (int) $atts['num'];

    // Init:
    $html="";    
    $ranges = explode( ',', $images );

    // Loop over input ranges:    
    foreach( $ranges as $range )
    {
        $rng = explode( '-', $range );

        if( count( $rng ) == 2 )
        {
            $from = (int) trim( $rng[0] );
            $to   = (int) trim( $rng[1] );

            foreach( range( $from, $to ) as $i )
            {
                 $html .= sprintf( '<img src="https://wordpress.stackexchange.com/questions/151395/%s/%d/%s.%s" alt="%s"/>', 
                     $path,
                     $num,
                     $i, 
                     $ext,
                     $title 
                 );
            }
        }
    } 

    return $html;
}

It might be faster for a very large loop to skip sprintf(), I use it here for better readability.