PHP uploading an image with my CMS? - php

I've built a php CMS and for my news page I want the option to either add one main image or the possibility of multiple images at the bottom for news stories with sponsors etc.
The basic article will have a square image on the left of the main content. I've coded it so the main image on upload is names the same as the article id.
I was thinking of adding an option to my database for 'bottom images' and have an upload option for when this is set to yes.
What would be the best way to go about this? I'm working in php and mysql.
Any help would be great thanks!

Create a table called:
article_images (id, article_id, image_path, image_type, published, added_datetime)
here, image type will choose what type of image. You can store many rows of image data for a single article. The image type will choose where to put the images: (main image, bottom image, etc...)
Please have a look.

Best way to do is use any WYSIWYG editor like tinyMCE or CKeditor. You wont need to worry about managing imaging separately.

Related

Add custom class to images in wordpress uploader

I have a site that has a script pulling images uploaded to a post and displaying it on their respective posts with the masonry script.
The issue is that I would like to have different widths on some "key images". The only thing that I thought of that could work is if there's a way to add a class to images being uploaded (before inserted).
For example under URL, Title, Caption etc.
Those classes could be radioboxes with small, medium or large.
Right now the only way to style images are after they're actually inserted in the post and I don't want to do that since they are never inserted and I don't want to mess up the text.
Does anyone have an idea?
Here's a link to a post for clarification.
http://www.lokalxxxarkitekter.com/web/projekt/broar-infrastruktur/kaptensbron/
Regards, Marcus

Blog posts and the common layer

I am using Joomla to design a website, very simple, there is a page on my site that is to store all news headlines (each is href) and each href leads to a full article, I would like to post an image in all of the articles, where can I put my image into in joomla folders so that right after each article title, the image will be shown ?
Thank you
To insert image in each article you have to follow this steps:
Administration->go to Article manager->CLick on article(view the article detail).
2.Now you can see the edition where you putted your article content.now on same editor there is an option of image.select it and choose image from the folder in which you putted the images.
now apply or save the article.
hence you will add image to each article in joomla.
You can put the images into any folder you want. All you have to do is go to each article in the backend and manually insert an image by typing in the path. Easier thing to do would be to create a folder in the "images" folder so that the insert path isn't too long.
As fr inserting, I'm not sure if you wanted all the images to be inserted automatically, but I am pretty sure this isn't possible.

handling images, videos, docs for custom cms

I am in the process of building a CMS using php, however I am struggling on how to handle the various different assets that a dynamic page could serve, typically an average page will contain pictures of various sizes(thumb, body, main, etc), inline images and various different assets(pdf, flv, mp4, doc, etc).
At the moment a user can upload assets and create a folder on the server, I just wanted some techniques and concepts on how to manage this in terms of deleting, editing and linking to my dynamic pages within the cms? I already have a content table which contains all the content(meta_stuff, title, friendly_url, content_text, etc).
On upload should a reference be stored somewhere in say a asset table?
Should all paths to assets(images, docs, videos,etc) be stored in one table? or separate for each asset?
Should multiple image sizes(small, medium, large, etc) be stored in different fields e.g(assetid, smallpath, mediumpath, largepath?
What technique to use to link assets to the dynamic page? should this be a joined table or single? how do I go about retrieving the different assets for a page several pdfs and several images?
How to handle deleting of assets as this could be referenced to another dynamic page?
and anything else you think would be beneficial?
Thanks for all your help
Here are some basic things to keep in mind when dealing with resources (videos, images, documents..) in a scenario similar to what you're describing.
You'd want is to know what's being uploaded, what kind of stuff are being uploaded and who's uploading. To do that, it's good to have the following tables:
Edit: Sorry about the mistake, asset_types.asset_type_id should be linked to assets.asset_type_id and NOT assesst.asset_id
(Note: This is just an outline, of course you'll have more fields)
This model makes it easy to do the following tasks
Upload: When something is uploaded, you store it somewhere (with the correct
.htaccess configurations) then store that path in the table.
Delete: When the user is trying to delete something, you check if he's the owner.
When you want to add a new type, you don't need to create a new table.
Hopefully this will put you in the right direction.
Update: Answering your comment, when a user wants to add an image to an article for example, you have two options here:
The user is presented with a button/select menu/whatever to choose the desired image, once clicked it will add <img src=LINK_TO_RESOURCE" /> to the body of the content (Make sure you protect yourself from XSS).
OR
You use your own simple markup, when the user clicks on an image this [[PREFIX_IMG:IMG_ID]] will be added to the body of the content, when the content is viewed you'll replace that "tag" with <img src="LINK_TO_RESOURCE" /> which you've acquired using IMG_ID.
2nd Update: Well you have a couple of options to handle resources that aren't directly embedded in the "articles" themselves.
You can have a field in the "articles" table you can call summary for example, and one more column to the assets table which you can call asset_sub_type and have different types like summary. Then when you want to view the summary you fetch the summary text/title from database and you add the resource to it.
(This is the technique I use) When fetching the summary from the database I see which image is the database that is related to that article and the resize it on the fly with PHP and append it to the summary.

PyroCMS - Pyrostreams multiple file upload on one entry

I've got the PyroStreams module for PyroCMS and made a stream called portfolio. Everything is working as expected, however it only allows to upload just one image for my file field. That is obvious, but I'd like to know if there's a way to upload multiple images for one stream entry without adding x number of extra file fields. Or do I need to code an extra field type myself to support this? Maybe someone's got it already?
Thanks
According to me you have to create a separate database table that will hold all the images those are related to particular portfolio and the portfolio id by id by which you can fetch the images for particular record and then use any multiple image upload library like http://www.plupload.com/example_queuewidget.php to upload multiple images in the portfolio image table. Hopefully this will help you in achieving what you want.
There's a multi-upload files field type available on the pyrostore.

Drupal 7:replace original image with ImageStyles generated image

I'm using regular imagefields on various content types in a Drupal 7 social website (and also on the user profile pictures via http://drupal.org/project/imagecache_profiles). For cropping I'm using http://drupal.org/project/imagecrop as an image style effect.
I would like to replace the original image with the one generated from the imagecrop style. How do you replace the original image from a user (the one that gets used for subsequent image styles when you say call it in views) with one that is created from an image style effect?
I'm not sure the best way to approach this problem, which is why I posted question.
To make sure I'm being clear -
A User uploads a large image (say 2,000 pixels by 1300 pixels) via a regular imagefield.
Using image styles, I perform some effects (specifically javascript crop, but this could be generic) and then replace the original image with the one generated from the image style.
All additional image styles (different sizes etc) use the new original images and are derived from it.
I think this can be done easily using a custom module and they must have used something like the image editor project - See drupal.org/project/imageeditor, just not sure what hooks to use or how to jump in on this. Any advice, tips or direction would be great.
Check module - Original image with style
I believe you can address your problem by making changes under the display settings for your field:
/admin/structure/types/manage/[your content type machine name here]/display

Categories