Storage: record image dimensions in database

    • 45 posts
    January 29, 2018 10:59 PM EST

    It would be great if we were able to store uploaded image's height and width in database and display it in view scripts. For example in "engine4_storage_files" table have 2 columns for "width" and "height" in pixels, and populate it for the files of type that have dimensions.

    I have came across many things that require photo dimensions, some examples are:

    JavaScript gallery sliders: most of them with advanced features require photo dimensions to function correctly. (ex. PhotoSwipe).

    OpenGraph: It's recommended to supply image dimensions together with "og:image" tag.

    I'm sure if I think about it the list will go on.

    For now I'm using php functions to open the image and extract dimensions information, but this is very inefficient and takes about .3 seconds per each image.


    Now I may be wrong but I don't think this can be done using a module or something like that as it's a core change. Also the script already checks image dimensions for resizing etc. so I don't think it will even take any effort to implement this.