1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Storing thumbnail sizes in database

Discussion in 'Databases' started by squishi, Apr 2, 2010.

  1. #1
    Hi!

    I've been pondering over this for days now.

    I want my script to be flexible and have a variable amount of thumbnails.

    Every page and post can have several thumbnails. The sizes for these thumbnails are stored in a separate table.
    This separate table will define the thumbnail sizes that are possible, so that i can later add thumbnail sizes or make changes.

    A picture describes best of what I have right now:
    [​IMG]

    Thumbnail_sizes will contain something like this:

    id / internal_id / type / width / height
    1  / 0           / post / 100   / 100
    2  / 1           / post / 220   / 220
    3  / 2           / post / 300   / 300
    4  / 0           / page / 400   / 400
    
    Code (markup):
    Thumbnails either belong to a post or page. The thumbnail 'type' is used to identify the thumbnail size and to let the user of the script define different thumbnail sizes for posts and pages in the script.
    The internal_id of the thumbnail size is used in several places in the output of the script to identify which thumbnail size should be used. So I would for example query the thumbnail with internal_id=0 as post thumbnail on the homepage and thumbnail with internal_id=1 as post thumbnail on a user's profile.

    A typical query will select the post data, the url of a matching thumbnail with a certain internal_id and its width and height.


    I really don't like how I have set this up. Queries are long and complicated.
    But I can't come up with a better way!
     
    squishi, Apr 2, 2010 IP
  2. islandhopper8

    islandhopper8 Active Member

    Messages:
    100
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #2
    Ever thought of using a script that resize the images "on-the-fly" so that you can create any size that you want. You also have the possibility to crop images to have them all the same size as a square (without deformation) or have them resize to squares with deformation. So you just make on image table which hold the original size of the image and you store the sizes of the images in the posts or pages table, which you use to resize the image.
     
    islandhopper8, May 24, 2010 IP
  3. mrx345

    mrx345 Peon

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don’t really understand what is the purposes of this but THUBNAIL_SIZE looks weird…
    You better store it in THUMBNAIL table.
    Don’t make thing that complicated.. size is an attribute of a thumbnail or picture right?
    Unless you have something like paper format - A4, legal, etc, but it looks like this is not your case.
     
    mrx345, Jul 27, 2010 IP