WordPress > Post-specific images with uploader and add/remove tool - wordpress

I'm looking to find a WordPress plugin that ads an upload widget to my post editor to allow me to associate images with posts.
The end result is that I can add a bit of code to my theme's single.php file that allows me to load all of the images that reside in the folder matching the post id.
If no such plugin exists, I'm looking for some help on creating one.
Here's the way it would work..
Any images uploaded to a specific post, will go into a folder named after the post id. For example, if you are editing the post with id=420, the uploaded files will go into a folder named "420". There would also need to be some way to add or remove images from the folder without leaving the post editor (though FTP could be used for this as well).
To show post specific images, the single.php file checks to see if there is a folder under wp-content/uploads matching the post id. If it finds a match, it simply loads all the images it finds in the folder.

You can already attach images to a post without including them in the main content. You can do all of this in the main Edit Post window (the first icon next to "Upload/Insert" above the text editor. They are added with the post id as parent_id parameter, so the get_children function will give you all attached files.
This will store the images in the standard /wp-content/uploads/ folder, grouped by year and month (if you checked that option in the administration page). If you want to change the upload directory, you can use the upload_dir filter (slightly outdated parameter list) and return a different upload directory, for example with the post ID. The upload_dir filter is called from wp_upload_dir(), which is called by wp_handle_upload(), which is called by media_handle_upload(), which is called from the media-upload.php file.
If you want to extend this idea and check the upload dir for new files (uploaded via FTP for example), and attach these to the post, I suggest you look into the attachment functions.

Related

Apache solr search result view Drupal 7

I am working Apache solr search its working fine. But I need to change the search result to my view like title, date, short description and image.
Can you please someone help me. How to override the search result to custom result.tpl page.
There are several options :
Altering/adding template variables for individual search result by implementing hook_preprocess_search_result().
Altering the template file itself search-result.tpl.php (first you need to copy the original in your theme's templates folder).
The same can be done on the entire set of results (rows per page) using search-results.tpl.php & hook_preprocess_search_results().
Add custom CSS or override some rules in your theme.

Organizing Media Files on Category basis

I've just started learning the WordPress CMS, i have a small PHP programming background and i wanted to masters in WordPress now. for the learning sake, i have started a project on my local server, Where user can register, login and upload images afterwards.
My Question is that, how do i organize all media uploads to a Category Base directory, all uploads should go to a specific directory based on user selection. If user selects "PLACES" category then the uploaded image/file should go to Places directory.
-Thanks
UPDATE
If the above option can not be achieved then how about creating a directory with post slug? like year/month/day/post-slug/images goes here
Only your written articles can be sorted by category.
Unfortunately there is no folder system for images. The only thing you can do is writing a post, import a image into the article and assign a category to the article. But anyway, assigning a category to a image is not necessary.

Create Folder Structure to Organize Content in Umbraco

I have many pages in the content section of Umbraco but some of the pages I would like to organize for departmental reference not necessarily for hierarchical site reference. For example, my pages might be A, B, C, D ... Z on the website but on the backend we have various teams that need their content grouped together. i.e. Team 1 folder has A-G in it. Team 2 folder has H-Q. Team 3 has R-Z in it. How can this be achieved so instead of seeing all the content on the root of the content page I only see these 3 team folders?
You have to be carefull in achieving this. When you create new nodes under your Home root node, eg new pages or folders, they are referenced with an url.
So If you have a page called A, this will be accessed using the url http://www.example.com/a. When you create folders to organize pages and you place page A under HQ, then your page will now be accessed by http://www.example.com/hq/a.
After that you can use url rewriting rules to avaid these folders indications in your url but that will be messed up if you have many pages.
I will suggest if you don't want to see these folder indications in your url, to just add all the nodes under your Home node and using Permission to allow/disallow departments to the nodes.
If you don't care about the folder indications in your url, let me know then I will edit this answer with the solution to achieve this.
EDIT
How to add folder structure in your content nodes.
Step 1
Create a new Document Type called Content Folder.
Go to Settings > Document Types > click on the 3 dots > Create.
Give it the name Content Folder.
As icon select the folder icon
Add a new property Redirect with alias umbracoRedirect with type Content Picker
Save changes
The builtin property umbracoRedirect is used to redirect one node to
another using its id. So for each folder set this property to the first child page.
Step 2
Allow your child node types in this folder.
Go to the structure tab of your Content Folder property
Check the child types that you want to allow under this folder
Save changes
Step 3
Allow this folder under your root Home node.
Go to the structure tab of your Home root property
Check the ContentFoldertype to allow as a child
Save changes
Step 4
Add you folder structure and add pages.
Go to your content
Add a new folder under your root node of type Content Folder
Give it the name HQ
Add a new page called A that's allowed under your folder
In your HQ set the Redirect property to your first A page
Do this for all your folders and pages
Save changes and publish
And thats it!
Another way of doing this is with a custom URL Provider and Content Finder. This is where you create a new provider for working out the URL of the pages on your site, overriding the default folder structure.
You can add your own logic out strip out folders from the URLS, so /folder/a/content could become /folder/content. Obviously you'd need to be careful that the other folders don't contain items with the same names, or you may get the wrong content returned.
The advantage of a URL Provider is that whenever you call the Umbraco methods to get the URL of a content item, you'll ALWAYS get the custom URL.
The content finder is a way for the site to match the modified URLs back to the original content. You'll need both for it to work.
Here is a link to an in depth article about using these two in conjunction in an Umbraco site.

WordPress: Can I batch upload lots of files (e.g. via a custom field) which will appear on my website as a list of downloadable files?

TL;DR: Can I upload hundreds of files via WordPress (vanilla or with free/premium plugins) which will appear on my website as downloadable files, or would another CMS be better suited to this task?
More info: I'm building a site to replace an old WordPress MU site. My (non-technical) client needs to be able to create a single profile page for each of their employees. Each employee page must include some or all of:
A header image
A text intro
A photo gallery
A list of links
Multiple audio embeds
Multiple video embeds
A list of ~1000 downloadable files, mostly pdf/jpg, divided into subgroups
Ideally the last point would be achieved something like this:
Client adds a custom field and must name it
Client drags any number (realistically 1-100) of files onto the field, or uploads via "add files" function
Files are saved in the backend to a folder named after the custom field
File order is editable by client
The field is output to the HTML page like this:
<h1>Custom Field Name</h1>
<ul>
<li><a>file1.pdf</a></li>
<li><a>file2.jpg</a></li>
...~100
</ul>
Employee A is totally separate from Employee B, C, etc. All employees' pages will be managed by a single user. Their files should exist separately in the backend. The paths to their files will ideally include their name, but only the filename itself needs to be printed to the page. A file system like this would be perfect:
/EmployeeFirstName-EmployeeLastName/Media/YYYY/Filename.xxx
I believe WP's default media file save directories can be customised via plugins.
I'm trying to do this in WP because it's what I've used in the past and it's what my client is familiar with. A friend recommended the Advanced Custom Fields plugin for WP, which I am looking into. I'm an experienced designer but a beginner developer. I accept my naïveté and I'm keen to learn.
Possible structures:
A single WP install with a Page per employee
A Multisite WP install with a Site per employee
Other?
After much searching I'm beginning to think WP might not be a suitable platform for long and busy pages (~80 video embeds per page, added via ACF) with this type of file management requirement. The admin page for my test page is already very slow to update and I haven't even started the file list part.
Since the key feature of this page template will be the ability to list hundreds of downloadable files, it seems logical to me to pick a CMS based on that requirement, rather than pick a familiar CMS and try to force it to do what I want.
Thanks for reading!
I have used
Download Attachments plugin which provide facilities to upload attachment as post meta from admin panel and user can download it from front end. Try it might help you.

WordPress Media as a Custom Post Type

I am building a WordPress website that will allow members to upload media such as videos, images, etc. They will do this on a public form at for example: domain.com/upload
The form will ask for a Title, a brief summary, show some categories to choose from, and finally a file uploader. The user will then be able to submit the form and it will appear on the site as a post but instead of being just text it is a piece of media.
I have created a custom post type and all seems to be fine, the problem I have is how to deal with the media upload, as the default WP method is to upload an item and then manually insert it into the post (and you can have as many inserted as you like). Where as I want users to be only able to upload one file per post and not have to insert the file into a post because the file itself is the post. They will also be able to upload a featured image.
Any ideas on how I can develop this? Thanks.
You could use WP upload methods to upload your file to the server. Then (depending on your upload's media type) you would insert HTML representation of the file into the post (e.g. parse a text file, create tag for image or embed a video).
If you want to see some working example, please let me know. I just outline the flow:
wp-handle_upload() to physically upload a file
wp_update_post() or wp_insert_post() depending on whether you're creating a new user post or editing existing one. Both methods require one argument - Post object. That's where you put your content (as a post_content field of course) and post data

Resources