Download the PHP package aysnc/wordpress-dynamic-media without Composer

On this page you can find all versions of the php package aysnc/wordpress-dynamic-media. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wordpress-dynamic-media

WordPress Dynamic Media

GitHub Actions Maintenance

Automatically transform WordPress media URLs into dynamic, optimized URLs powered by image transformation services like Cloudinary.

Requirements

Installation

The plugin auto-activates through Composer's wordpress-plugin type. If your setup doesn't support that, activate it manually in wp-admin.

What It Does

When you upload an image to WordPress, it gets stored at a URL like this:

With this plugin active, that same image is served through Cloudinary with on-the-fly transformations:

The plugin hooks into WordPress's image handling at multiple levels, so this happens automatically - no need to change your templates or content.

Here's what gets transformed:

REST API Support

The plugin transforms URLs in REST API responses by default. When you fetch media via /wp/v2/media, both source_url and all size URLs in media_details.sizes are transformed.

This is enabled by default. To disable it globally:

Or disable it per-request (useful for admin/editor contexts):

Generating URLs

The real power is in generating dynamic URLs on demand. Given any attachment ID, you can build a URL with whatever transformations you need.

The Basics

These parameters work across all adapters:

Adapter-Specific Transforms

Need more than dimensions? The transform array lets you pass parameters directly to your adapter:

On portability: width, height, and hard_crop work across all adapters - the plugin translates these for each service. The transform array does not. It's passed directly to your adapter, untouched.

This is intentional. Image services have different capabilities - Cloudinary's gravity: 'face' has no equivalent in every provider. Rather than maintain a leaky abstraction, we give you direct access. The trade-off: if you switch adapters, any code using transform needs to be updated.

Best practice: Don't call Media::get_dynamic_url() with transform scattered throughout your codebase. Wrap it in your own function:

That way if you change adapters - or just want to tweak your transforms - you have one place to update instead of hunting through templates.

Configuration

The plugin needs to know your Cloudinary details. Add this filter to your theme or a mu-plugin:

That's the minimum config. The auto_mapping_folder should match the folder name you set up in Cloudinary's auto-upload settings.

Full Configuration Options

Option Default Description
cloud_name (required) Your Cloudinary cloud name
auto_mapping_folder (required) The folder configured in Cloudinary's auto-upload mapping
domain res.cloudinary.com Custom domain if you're using a CNAME
default_hard_crop fill Cloudinary crop mode for hard-cropped images
default_soft_crop fit Cloudinary crop mode for proportionally-scaled images

Using Environment Variables

Since configuration happens through a filter, you can pull values from wherever makes sense for your setup:

Hooks & Filters

aysnc_wordpress_dynamic_media_config

Global plugin configuration.


aysnc_wordpress_dynamic_media_rest_enabled

Control REST API transformation on a per-request basis. Receives the request and attachment objects for context.

Parameters:


aysnc_wordpress_cloudinary_config

Configure the Cloudinary adapter. See Configuration above.


aysnc_wordpress_cloudinary_args

Modify transformation arguments before the Cloudinary URL is built. Use this for site-wide settings like auto-optimization:

This filter is Cloudinary-specific. If you switch adapters, you'll replace this with the equivalent for your new service.

Supported transformation parameters:

Parameter Cloudinary Parameter Cloudinary
width w height h
crop c gravity g
quality q fetch_format f
effect e opacity o
radius r angle a
background b border bo
overlay l underlay u
dpr dpr zoom z
aspect_ratio ar flags fl
progressive fl_progressive named_transformation t

See Cloudinary's transformation reference for the complete list.


aysnc_wordpress_dynamic_media_url

Modify the final dynamic URL before it's returned. Works with any adapter.

Parameters:


aysnc_wordpress_dynamic_media_srcset_dimensions

Adjust dimensions for individual srcset entries.

Parameters:


aysnc_wordpress_dynamic_media_content_image_src

Override the URL for images in post content. Return a string to use your custom URL, or null to let the plugin generate one.

Parameters:


aysnc_wordpress_cloudinary_upload_url

Override the base upload URL used to determine the path within Cloudinary. Useful for multisite or custom upload configurations.

Custom Adapters

The plugin uses an adapter pattern, so you can add support for other image services:

Switching Adapters

If you have multiple adapters registered, you can switch between them:

Pausing the Plugin

Need to temporarily disable transformations? Maybe for debugging or a specific request:

Development

Setup

Running Tests

Code Quality

Full Test Suite


All versions of wordpress-dynamic-media with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aysnc/wordpress-dynamic-media contains the following files

Loading the files please wait ...