=== Media Tags ===
Contributors: neatwp
Tags: media, tags, gallery, media library, attachments
Requires at least: 5.0
Tested up to: 6.6
Stable tag: 1.2
Requires PHP: 7.0

Add tags to media files in WordPress, filter them in the media library, and display tagged media in galleries using a flexible shortcode.

== Description ==

Media Tags is a lightweight WordPress plugin that enhances media management by allowing you to add tags to media files. Organize your media library efficiently with custom tags, filter media by tags in the admin interface, and showcase tagged media in front-end galleries using a powerful shortcode. Perfect for photographers, bloggers, and site administrators who need better control over their media assets.

**Key Features:**
- Add and manage tags for media files in the WordPress media library.
- Filter media by tags in the admin media library with clickable tag links.
- Bulk edit tags for multiple media files at once.
- Autocomplete tag suggestions for easy tag management.
- Display tagged media in galleries using the `[neat_media_tag_gallery]` shortcode with customizable options:
  - Filter by single or multiple tags with OR/AND logic.
  - Sort media by date, title, or random order.
  - Control image size, number of columns, and link behavior.
- Seamless integration with WordPress core media functionality.

Whether you're organizing a large media library or creating dynamic galleries, Media Tags makes it simple and efficient.

== Installation ==

1. Upload the `media-tags` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Go to the Media Library to start adding tags to your media files.
4. Use the `[neat_media_tag_gallery]` shortcode in your posts or pages to display tagged media galleries.

== Usage ==

1. **Tagging Media**:
   - In the Media Library or when editing a media file, use the "Media Tags" field to add tags (comma-separated).
   - Use bulk edit in the Media Library to tag multiple files at once.

2. **Filtering in Media Library**:
   - In the Media Library, click on a tag in the "Media Tags" column to filter media by that tag.

3. **Displaying Galleries**:
   - Use the `[neat_media_tag_gallery]` shortcode with the following attributes:
     - `tag`: Comma-separated list of tag slugs (e.g., `tag="landscape,portrait"`).
     - `logic`: Filter logic, either `OR` or `AND` (default: `OR`).
     - `size`: Image size (e.g., `thumbnail`, `medium`, `large`, `full`; default: `medium`).
     - `columns`: Number of columns in the gallery (default: `3`).
     - `link`: Link type (`file` for direct image, `attachment` for attachment page, or empty for no link; default: `file`).
     - `orderby`: Sort order (`date`, `title`, `RAND` for random; default: `date`).
     - `order`: Sort direction (`ASC` or `DESC`; default: `DESC`; ignored if `orderby="RAND"`).
     - `limit`: Maximum number of images to display (default: `0` for all).

   **Example Shortcodes**:

[neat_media_tag_gallery tag="landscape" size="medium" columns="3" link="file" orderby="date" order="DESC" limit="10"]

Displays up to 10 media items tagged "landscape", sorted by date (descending).

[neat_media_tag_gallery tag="landscape,portrait" logic="AND" size="large" columns="4" orderby="RAND" limit="8"]

Displays up to 8 media items tagged with both "landscape" and "portrait", in random order.

== Frequently Asked Questions ==

= How do I add tags to media files? =
In the Media Library, edit a media file or use the bulk edit feature. Enter tags in the "Media Tags" field, separated by commas. Tags will autocomplete as you type.

= How can I filter media by tags in the Media Library? =
In the Media Library grid or list view, click on a tag name in the "Media Tags" column to filter media by that specific tag.

= What does the `logic` attribute do in the shortcode? =
The `logic` attribute (`OR` or `AND`) determines how multiple tags are handled:
- `OR`: Displays media with any of the specified tags.
- `AND`: Displays media that have all specified tags.

= Can I display media in random order? =
Yes, use `orderby="RAND"` in the shortcode to display media in a random order. For example: `[neat_media_tag_gallery tag="landscape" orderby="RAND"]`.

= Why don't I see my tags in the gallery? =
Ensure the tag slugs are correct and that media files are tagged with them. Also, check if the `logic` attribute is set appropriately (e.g., `AND` requires media to have all tags).

== Screenshots ==

1. **Media Tags Field**: Adding tags to a media file in the Media Library.
2. **Media Library Filtering**: Clicking a tag in the "Media Tags" column to filter media.
3. **Bulk Edit**: Adding tags to multiple media files using bulk edit.
4. **Gallery Shortcode**: Example of a gallery displayed with `[neat_media_tag_gallery]`.

== Changelog ==

= 1.2 =
* Added support for random ordering in the `[neat_media_tag_gallery]` shortcode using `orderby="RAND"`.
* Release Date: August 7, 2025

= 1.1 =
* Fixed media library tag filtering to correctly display media when clicking tag links.
* Added OR/AND logic to the `[neat_media_tag_gallery]` shortcode with the `logic` attribute.
* Ensured all text is in English with proper text domain usage.

= 1.0 =
* Initial release with media tagging, bulk editing, autocomplete, and gallery shortcode.

== Upgrade Notice ==

= 1.2 =
Adds random ordering for galleries with `orderby="RAND"`. Update to enhance gallery display options.

= 1.1 =
Fixes media library tag filtering and adds OR/AND logic to the gallery shortcode. Upgrade for improved functionality and reliability.
