Responsive iframe with fixed aspect ratio

    Follow

    When embedding videos in pages, it may be nice to be sure that the player has a fixed aspect ratio independently of the proportions of the original video.

    To achieve this, modify the XML-RPC call retrieving a regular iframe embed code:

    options = {'embedtype': 'iframe',
       'playerwidth': '100%', 'playerheight': -1}
    embed = xmlrpcserver.getPresentation(common, mediaid, 0, options) 
    

    with one that explicitly specifies the aspect ratio, e.g. 16:9:

    options = {'embedtype': 'iframe',
       'playerwidth': '100%', 'playerheight': -1, 'ratio': 9.0/16.0}
    embed = xmlrpcserver.getPresentation(common, mediaid, 0, options) 
    
    Was this article helpful?
    0 out of 0 found this helpful

    Comments