Blog posts and the common layer - php

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.

Related

Deleting attached files when its post deleted

Imagine there is writing article application, The article would have some pictures, files, etc. Of course, when the article removed, attached files should be removed too. But How can I do that?
There is write form, in
/news/write. When I uploads some picture, the picture will send to the server in background, (by ajax post). and this picture will have some name, like a0bb880c5a06b5b9dc238f84cfda6861, it will be appended in the editor <img src="/uploads/a0bb880c5a06b5b9dc238f84cfda6861">.
I don't finish the article, but the picture in the server. Finally I submit the post, and there is picture with in it, And later few hours, I want to delete it. No problem with delete article itselt, but the picutre remains in the server. I want to delete it too.
I think some ways, The conclusion is, I should bind article and its picture.
Mapping files and article - But how can I do that? the article not exist, so I don't know article's id.
When article saved, parsing content and pick up <img> tag's src attribute, and connect it. Should I do like this? Is there any easier way?
Or delete files periodly ...?
You need to make a relation with your article and image files to be able to delete the image file when article is deleted.
You can also parse through the content of the articles and find images and delete them but I think that will be bad way to do it.
Instead try this.
When you save articles you can save images files in a field of the articles document.
db.articles.insert( { title: "article title", body: 'article body', images: [{imageFileName: 'xyz.jpg'}, {imageFileName: 'xyz.png'}...] } );
Now when you delete article you will have images field that you can iterate through and delete the image files as well.

Dynamic image table in PHP from mysql db

I am trying to create a php page that reads a list of films from a database and displays the corresponding images in a table.
I've found quite a few examples of this, but havent successfully been able to implement it yet.
Has anyone got a link to a good tutorial on doing this or perhaps code you've used yourself?
so my images are stored in a folder 'images' on a server, and each entry in my table contains the colulmn 'imagelocation' which has a relative location, like "images/film1.jpg".
Ultimately the images will be clickable and will open a lightbox type view with the image and full info about the film.
any help appriciated!

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.

PHP uploading an image with my CMS?

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.

How do I make a gallery in WordPress without using a plugin?

I have created a gallery in a WordPress post using WordPress's native media gallery and it shows me the images as gallery thumbnails in rows and columns which is exactly what I want.
But when I click on any of the thumbnail it opens the direct image link. I want that the image should be shown in my blogs environment. I would actually want it to show on the same page itself. but if not that I don't want it to open as a direct image. Is there a template file or something I could make for opening those images. I think image.php, but I have no idea how to go about it.
Help..?
Thanks
When you're inserting a gallery into your post, you can select how to link to the images. See screenshot: http://cl.ly/2yYA
Just select 'attachment page' and you'll get an individual page with commenting for that photo. Is that what you were looking for? You can edit the template of that page using attachment.php.

Categories