=== Auto Title & Alt Sync ===
Contributors: aanees61
Tags: media, images, alt text, title, seo
Requires at least: 5.0
Tested up to: 7.0
Stable tag: 1.0.1
Requires PHP: 7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically generates alt text from image filenames on upload and provides bi-directional sync between Title and Alt fields in the Media Library.

== Description ==

Auto Alt & Title Sync is a powerful WordPress plugin that streamlines your media workflow by automatically populating alt text from image filenames during upload. It also provides real-time bi-directional synchronization between the Title and Alt fields in the Media Library, saving you time and improving accessibility.

= Key Features =

* **Auto Alt Generation**: Automatically generates alt text from image filenames on upload
* **Smart Formatting**: Converts filenames to readable text (removes dashes, underscores, dots, etc.)
* **Title Case Conversion**: Automatically converts alt text to proper Title Case
* **Bi-directional Sync**: Changes to Title auto-update Alt, and changes to Alt auto-update Title
* **Real-time Updates**: See changes instantly as you type in the Media Editor
* **Media Modal Support**: Works in the media modal when adding images to posts/pages
* **Manual Sync**: One-click sync button in the media editor
* **AJAX Powered**: Fast, seamless synchronization without page reloads
* **Lightweight**: Minimal impact on performance
* **Translation Ready**: Fully internationalized

= How It Works =

1. **Upload an image** → Alt text is automatically generated from the filename
2. **Edit the Title** → Alt text updates in real-time
3. **Edit the Alt text** → Title updates in real-time

= Example Transformations =

| Filename | Generated Alt Text |
|----------|-------------------|
| `beach-sunset.jpg` | Beach Sunset |
| `product_123_main.png` | Product 123 Main |
| `my--photo---best.jpeg` | My Photo Best |
| `screenshot-2024-01-15.png` | Screenshot 2024 01 15 |

= Benefits =

* **Save Time**: No more manually typing alt text for every image
* **Improve Accessibility**: Proper alt text makes your site more accessible
* **Boost SEO**: Better alt text improves search engine rankings
* **Consistency**: Uniform formatting across all your images
* **User Friendly**: Intuitive sync between Title and Alt fields

= Compatibility =

* Works with all WordPress themes
* Compatible with Classic Editor and Block Editor (Gutenberg)
* Works with major page builders (Elementor, WPBakery, etc.)
* Supports all image formats (JPG, PNG, GIF, WebP, SVG, etc.)

== Installation ==

= Automatic Installation (Recommended) =

1. Go to **Plugins → Add New** in your WordPress admin
2. Search for "Auto Alt & Title Sync"
3. Click **Install Now** and then **Activate**

= Manual Installation =

1. Download the plugin ZIP file
2. Go to **Plugins → Add New → Upload Plugin**
3. Upload the ZIP file and click **Install Now**
4. Click **Activate Plugin**

= FTP Installation =

1. Unzip the plugin folder
2. Upload the `auto-title-alt-sync` folder to `/wp-content/plugins/`
3. Go to **Plugins** in WordPress admin and activate the plugin

== Frequently Asked Questions ==

= Will this plugin overwrite existing alt text? =

No. The plugin only generates alt text for new uploads that don't already have alt text. Existing alt text is preserved.

= Does this work with non-image files? =

No. The plugin only processes image files (JPG, PNG, GIF, WebP, SVG, etc.). PDFs, videos, and other file types are ignored.

= Can I disable the sync feature? =

The sync is always active, but you can modify the code or use hooks to customize behavior.

= Will this work with my theme? =

Yes! The plugin works entirely in the admin area and doesn't affect the frontend. It's compatible with all WordPress themes.

= Does this work with page builders? =

Yes. Since the plugin works at the Media Library level, it's compatible with Elementor, WPBakery, Beaver Builder, and all other page builders.

= How do I manually sync Title and Alt? =

In the Media Library, edit an image and you'll see a "Sync Now" button in the meta box. Click it to manually sync both fields.

= Can I use this for existing images? =

The plugin automatically processes new uploads. For existing images, you can use the manual sync button or write a custom script.

= Is this plugin translation ready? =

Yes! The plugin is fully internationalized and includes translation files.

= Will this slow down my site? =

No. The plugin is lightweight and only runs in the admin area. It has minimal impact on performance.

= What happens if I change the Title? =

The Alt text automatically updates to match the new Title in a properly formatted way.

= What happens if I change the Alt text? =

The Title automatically updates to match the new Alt text in a properly formatted way.

== Screenshots ==

1. Auto-generated alt text on image upload
2. Real-time Title to Alt sync in Media Editor
3. Real-time Alt to Title sync in Media Editor
4. Manual sync button in media meta box
5. Media modal sync support

== Changelog ==

= 1.0.0 - 2024-01-15 =
* Initial release
* Auto alt generation on image upload
* Bi-directional Title ↔ Alt sync
* Real-time updates in Media Editor
* Media modal support
* Manual sync button
* AJAX-powered synchronization
* WordPress 5.0+ compatibility
* PHP 7.0+ compatibility
* Translation ready

== Upgrade Notice ==

= 1.0.0 =
Initial release. Auto alt generation and bi-directional sync for Title and Alt fields in Media Library.

== Customization ==

= Filters and Hooks =

The plugin provides several filters for developers to customize functionality:

**aats_generated_alt_text**
Filter the generated alt text before saving.

`add_filter('aats_generated_alt_text', function($alt_text, $filename) {
    // Custom processing
    return $alt_text;
}, 10, 2);`

**aats_title_to_alt**
Filter the title to alt conversion.

`add_filter('aats_title_to_alt', function($alt, $title) {
    // Custom conversion
    return $alt;
}, 10, 2);`

**aats_alt_to_title**
Filter the alt to title conversion.

`add_filter('aats_alt_to_title', function($title, $alt) {
    // Custom conversion
    return $title;
}, 10, 2);`

= Action Hooks =

**aats_before_sync**
Fires before sync operations.

`add_action('aats_before_sync', function($attachment_id, $field, $value) {
    // Custom logic before sync
}, 10, 3);`

**aats_after_sync**
Fires after sync operations.

`add_action('aats_after_sync', function($attachment_id, $field, $value, $result) {
    // Custom logic after sync
}, 10, 4);`

== Developer Notes ==

= Plugin Constants =

| Constant | Description |
|----------|-------------|
| `AATS_VERSION` | Plugin version |
| `AATS_PLUGIN_DIR` | Plugin directory path |
| `AATS_PLUGIN_URL` | Plugin URL |
| `AATS_PLUGIN_BASENAME` | Plugin basename |

= Classes =

| Class | Description |
|-------|-------------|
| `AutoAltTitleSync` | Main plugin class |
| `AATS_Upload_Handler` | Upload and alt generation |
| `AATS_Sync_Handler` | Bi-directional sync logic |

= JavaScript API =

The plugin exposes `AATS_Sync` globally for developers:

`// Check if syncing
AATS_Sync.isSyncing

// Manually trigger sync
AATS_Sync.manualAjaxSync(attachmentId);

// Convert Title to Alt
AATS_Sync.titleToAlt(title);

// Convert Alt to Title
AATS_Sync.altToTitle(alt);`

== Contributing ==

Contributions are welcome! Please submit pull requests or report issues on the plugin's GitHub repository.

== Credits ==

Developed by Anees Ahmad

== License ==

This plugin is licensed under the GPLv2 or later.

== Support ==

For support, please visit the WordPress support forums or contact the developer.

== Donations ==

If you find this plugin useful, please consider making a donation to support development.