bbimg My attempt at photos…
-
bbimg My attempt at photos…
This is my first post in any sort of WordPress related project, and with me using it so much I finally wanted to start giving back. I have a few plugins and Ideas that I have been working on that I think I’ll just give away instead of hiding them away on whatever servers I put them on. I am starting to do a lot more work with elements that I cant find already made so I have to make them, but then I forget that someone else may need that same thing.
With that, I am the webmaster of a small(3,000 users) site that is a social network for models and those in the modeling agency. Right now its totally free as we are building a userbase. Soon that will change as well as the engine we are running on. It is old, slow, I didn’t make it, and wont scale so I have been searching for a replacement and I was going to use JoomSocial, but I decided against it as I would rather foster this project.
At the modeling website there are thousands upon thousands of images as that is the users primary resource and reason for being online. So I have decided to work on a plugin to handle the images and albums. I have written a outline in my project notebook, but would love some feedback. My plan is to update this thread as I progress.. I have a week until next semester so that should be plenty of time to get a beta out..
Some of this is in coding format, but no real lines of code yet..
HERE WE GO!!
- First the user clicks add photos, a page loads with a single field and a MORE button.
- once all photos are selected the user POSTS data to the same page.
(note) More AJAX’y stuff could go on here, but I’m keeping it simple at first..
- checks that file is image type, makes all lowercase, renames jpeg to jpg.
- all files converted to jpg(or whatever file type)
- Checks if height > width, then checks larger value against max_width/max_height.
- Resizes with correct ratio.
- sets image quality
- Generates filename from userID and photokey such as 1234_15.jpg
- Photo uploaded to image directory
It keeps the data as session data and moves to creating a thumbnail
- Admin sets weather to resize, crop, or scale images. Does so to set options
- Thumbnail uploaded to thumbnail directory (SAME FILE NAME)
Then comes what we are doing to the database.. I had TONS and TONS of ideas for this, and was trying to avoid creating MORE tables for each user, if they have a blog they already have 8!! So what I have done is added 4 fields to Usermeta, and created two sitewide tables called images and albums.
- Usermeta
- Photokey – key that a user adds to each time a image is uploaded. No duplicate image names in a database or directory.
- Albumkey – Same thing.
- Albums – Names of albums user has created, this is to relive querys to other tables as usermeta is loaded automatically.
- Tagged – This is ALL PHOTOS the user is tagged in, returns an array
The larger of the two tables is Images, it holds all the data for each image in the directory.
- Key
- image name – I used 1234_15.jpg earlier.. extension could be left off..
- user – this is so wp doesnt have to parse the image name.
- active – When a user elects to delete an image it is first switched to inactive, this gives the user time to “un-delete” a file, while also allowing an administrator to remove all files in a single action reducing storage size and server load. I plan on doing this during lower traffic hours as a cron job.
- albums – this is to reduce query load when someone wants to display the name of the album a image is in, and allows direct targeting of the album table.
- date – timestamp when uploaded.
- Caption
- Comments – my plan for now is a hack job of a very long array.. I dont think anyone will max out a data field for a image with too many comments..
- Tags – userid’s of those tagged.
Then the Albums table:
- key
- Album name – userid_albumkey
- userid – who made the album
- Title
- Caption
- Comments
- Date
- active
- List of image names in this album. Returns an array.
WHEEEEW!!
how to call it:
- get_album(“id”, maxdisplay, number of tags, number of comments,); returns markup
- get_img(“name”, options);
- get_thumb(“name”);
- get_img_data(“name”, options); if left blank all data is loaded as img_id, img_caption, etc..
- get_tagged_img(); returns a list of all images person has been tagged in.
- get_album_info(); same as img, useful if say you just wanted the names for a carousel or slider..
Of course tagging would call an event or whatever BB uses for its “wire” I havent learned enough of that code yet but Its in the works.
a user can un-tag themselves from any image, and it would remove it from the image database as well as the meta data. It would work the same when deleted..
What do you guys think? What should I kill immediately, or what should I add? I will have a TON of configurable options for admins, but didnt want to post all that.
Well thats it for now I guess, I’ll start coding the meat of it tomorrow..
-Dennis..
- The topic ‘bbimg My attempt at photos…’ is closed to new replies.