AddImageUrls by Robin S

Allows images/files to be added to Image/File fields by pasting URLs.

Add Image URLs

A module for ProcessWire CMS/CMF. Allows images/files to be added to Image/File fields by pasting URLs or using the API.

screencast

Installation


Install the Add Image URLs module.

Configuration


You can add MIME type > file extension mappings in the module config. These mappings are used when validating URLs to files that do not have file extensions.

You can define a user agent string for websites such as Wikimedia that require a User-Agent header to be set. Example:

AddImageUrls/0.0 (https://github.com/Toutouwai/AddImageUrls; yourname@yourdomain.com)

Usage


A "Paste URLs" button will be added to all Image and File fields. Use the button to show a textarea where URLs may be pasted, one per line. Images/files are added when the page is saved.

A Pagefiles::addFromUrl method is also added to the API to achieve the same result. The argument of this method is expected to be either:

Example:

// Get unformatted value of File/Image field to be sure that it's an instance of Pagefiles
$page->getUnformatted('file_field')->addFromUrl("https://domain.com/path-to-file.ext");
// No need to call $page->save() as it's already done in the method

Should you have an issue using the method, please have a look at the "errors" log to check if something was wrong with your URL(s).

WebP conversion

The core InputfieldImage does not support images in WebP format. But if you have the WebP To Jpg module installed (v0.2.0 or newer) then any WebP images you add via Add Image URLs will be automatically converted to JPG format.

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #549
    In the 549th issue of ProcessWire Weekly we’re going to check out the latest core updates, highlight one older yet still very relevant third party module, and more. Read on!
    Weekly.pw / 17 November 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“To Drupal, or to ProcessWire? The million dollar choice. We decided to make an early switch to PW. And in retrospect, ProcessWire was probably the best decision we made. Thanks are due to ProcessWire and the amazing system and set of modules that are in place.” —Unni Krishnan, Founder of PigtailPundits