Jump to content
Robin S

Add Image URLs

Recommended Posts

Add Image URLs

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

screencast

Usage

Install the Add Image URLs module.

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.

 

https://github.com/Toutouwai/AddImageUrls
https://modules.processwire.com/modules/add-image-urls/

  • Like 20

Share this post


Link to post
Share on other sites

Really useful module I consider to be this one, I have done something similar on one website but was not as elegant as this one.

Thank you for your work.

  • Like 2

Share this post


Link to post
Share on other sites

nice :)

do you think you could extend this module to also store images pasted from the clipboard? 

PS: i think it would be great if the images were added via AJAX right after pasting (either urls or clipboard). what do you think @Robin S ?

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, bernhard said:

do you think you could extend this module to also store images pasted from the clipboard?

I agree it would be handy, but that would be a completely different thing to what this module is doing. This module is essentially just using Pageimages::add() on the submitted URLs, and that method has no support for clipboard data. I don't think I want to disappear into the browser clipboard rabbit-hole with this module. :-)

5 hours ago, bernhard said:

i think it would be great if the images were added via AJAX right after pasting (either urls or clipboard).

I'll have a think about it. It would make the module significantly more complex and I'm not sure how much time I want to put into it. Maybe if I get bored sometime...

  • Like 3

Share this post


Link to post
Share on other sites

I'm getting an error on this...

Error: Uncaught TypeError: Argument 1 passed to ProcessWire\Pageimage::__construct() must be an instance of ProcessWire\Pagefiles, null given, called in /home/walking/public_html/site/modules/AddImageUrls/AddImageUrls.module on line 152 and defined in /home/walking/public_html/wire/core/Pageimage.php:109

Share this post


Link to post
Share on other sites
On 03/02/2018 at 1:30 PM, hezmann said:

I'm getting an error on this...

Can you give a more detailed report please?

  • What are the image URLs you are trying to add when you see the error notice?
  • Is the issue reproducible? i.e. if you try again with the same URLs do you see the same notice?
  • If you download the images to your computer and then upload as per a normal addition to an images field, do they work then?
  • Anything special about your images field - e.g. inside a Repeater or PageTable?
  • The error seems to be related to the field name. Could you please post a screenshot of your browser dev tools showing the source code of the textarea input that this module adds to the images field (like the one below)?

2018-02-05_101903.thumb.png.20073e94b74aaec6545dfec1222a2795.png

That will help me get to the bottom of this. Thanks.

 

Share this post


Link to post
Share on other sites

I've tried several URL's from various places - all get the same error

I get it with every URL so yes, reproducable.  I have not been able to save any images this way.

Saving the image and then uploading works fine.

Not inside a repeater or anything special, just a normal Images field

Full Error: image.thumb.png.fad8a91ee02bc55c323b1e2a18e494bc.png

 

Source Code

image.png.e5ff46b25d67dac405764089cc3b7c1c.png

  • Like 1

Share this post


Link to post
Share on other sites

@hezmann, if you can give me access to your dev site (send me a message) I would be happy to take a look. Otherwise I'm out of ideas sorry.

  • Like 1

Share this post


Link to post
Share on other sites

Hey @Robin S - I thought since I've been mucking about with a lot of modules and code I would do a clean install and see what happened.  I did a 100% clean install on a site that has literally never had anything on it (I owned the domain but have never used it).  Only added one field for images with one template.  Created a page and got this error:  image.thumb.png.b057755514b928016590e05782f264ac.png

I'll send you a message with login details to the new site.  Thanks!

  • Like 2

Share this post


Link to post
Share on other sites

v0.1.2 released - adds compatibility with PW < 3.0.66

  • Like 3

Share this post


Link to post
Share on other sites

Hey @Robin S, I thought this module was handy so I modified the AddImageUrls module and adapted it to work for file fields.

I attached the new "AddFileUrls" module.  Feel free to upload it to your github or publish these to the module directory.

It seems to work well in my testing.

Hope that helps

AddFileUrls.zip

  • Like 1

Share this post


Link to post
Share on other sites
On 1/1/2020 at 5:49 PM, gmclelland said:

I modified the AddImageUrls module and adapted it to work for file fields.

v0.2.0 released, which adds support for File fields so that file URLs can be added the same as with Image fields. Thanks to @gmclelland for the idea.

I've also submitted the module to the directory now seeing as it seems to be working well without any significant issues reported.

 

  • Like 2

Share this post


Link to post
Share on other sites

Thanks for adding this to modules directory and combining both module's functionality. 🎉

Not sure if this is possible, but sometimes you have sites that have file urls or image urls with no extensions.  Example: mywebsite.com/this-is-a-pdf-link or mywebsite.com/this-is-an-image

Urls like that won't work currently with this module.  I'm not sure if there is a way to add a check if the url doesn't have an extension, then check the mime type against the allowed extensions?

Maybe somehow comparing the two by using $config->fileContentTypes and $ctype = mime_content_type($file->filename); ?

Share this post


Link to post
Share on other sites
On 1/10/2020 at 7:34 AM, gmclelland said:

Not sure if this is possible, but sometimes you have sites that have file urls or image urls with no extensions. 

I've added support for these sorts of remote files in v0.2.1.

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Hi @Robin S, just wanted to let you know that I tried out the latest version, but it didn't seem to work with the file/image files with no extension.

Here are some examples that didn't work for me:

Ex. pdf file with no extension:

https://www.charleston-sc.gov/DocumentCenter/View/18787/Certificate-of-Construction-Completion-RES-Checklist?bidId=

Ex. image file with no extension:

https://www.charleston-sc.gov/ImageRepository/Document?documentID=23023

After saving the page with those urls, it shows the following error message:

AddImageUrls: The remote file https://www.charleston-sc.gov/DocumentCenter/View/18787/Certificate-of-Construction-Completion-RES-Checklist?bidId= has no file extension and its MIME type does not correspond with a valid file extension for field "page_files".

The file field is configured to allow pdf files and the image field is configured to allow png, jpg, jpeg, gif.

Do these urls work for you?

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, gmclelland said:

just wanted to let you know that I tried out the latest version, but it didn't seem to work with the file/image files with no extension.

This was due to $config->fileContentTypes not having up-to-date MIME types. I created an issue here and decided it would be better to make the MIME type > file extension mapping configurable in v0.2.2 rather than using $config->fileContentTypes. Please update the module and the problem should be fixed.

P.S. This page is a useful resource if anyone wants to set additional MIME type mappings: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

  • Like 3

Share this post


Link to post
Share on other sites

Thanks Robin, just tested and it does work. Man, you're fast!

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MoritzLost
      Process Cache Control
      This module provides a simple solution to clearing all your cache layers at once, and an extensible interface to perform various cache-related actions.
      The simple motivation behind this module was that I was tired of manually clearing caches in several places after deploying a change on a live site. The basic purpose of this module is a simple Clear all caches link in the Setup menu which clears out all caches, no matter where they hide. You can customize what exactly the module does through it's configuration menu:
      Expire or delete all cache entries in the database, or selectively clear caches by namespace ($cache API) Clear the the template render cache. Clear out specific folders inside your site's cache directory (/site/assets/cache) Clear the ProCache page render cache (if your site is using ProCache) Refresh version strings for static assets to bust client-side browser caches (this requires some setup, see the full documentation for details). This is the basic function of the module. However, you can also add different cache management action through the API and execute them through the module's interface. For this advanced usage, the module provides:
      An interface to see all available cache actions and execute them. A system log and logging output on the module page to see verify what the module is doing. A CacheControlTools class with utility functions to clear out different caches. An API to add cache actions, execute them programmatically and even modify the default action. Permission management, allowing you granular control over which user roles can execute which actions. The complete documentation can be found in the module's README.
      Plans for improvements
      If there is some interest in this, I plan to expand this to a more general cache management solution. I particular, I would like to add additional cache actions. Some ideas that came to mind:
      Warming up the template render cache for publicly accessible pages. Removing all active user sessions. Let me know if you have more suggestions!
      Links
      https://github.com/MoritzLost/ProcessCacheControl ProcessCacheControl in the Module directory CHANGELOG in the repository Screenshots


    • By Macrura
      PrevNextTabs Module
      Github: https://github.com/outflux3/PrevNextTabs
      Processwire helper modules for adding page navigation within the editor.
      Overview
      This is a very simple module that adds Previous and Next links inline with the tabs on the page editor. Hovering over the tab shows the title of the previous or next page (using the admin's built in jqueryUI tooltips.)
      Usage
      This module is typically used during development where you or your editors need to traverse through pages for the purpose of proofing, flagging and/or commenting. Rather than returning to the page tree or lister, they can navigate with these links.
      Warnings
      If you are using PW version 2.6.1 or later, the system will prevent you from leaving the page if you have unsaved edits.
      For earlier versions, to avoid accidentally losing changes made to a page that might occur if a user accidentally clicks on one of these, make sure to have the Form Save Reminder module installed.
      http://modules.processwire.com/modules/prev-next-tabs/
    • By EyeDentify
      Hello Dear PW Gurus.

      Hope you fair well in these Corona Crisis times.

      Anyhow, i have a problem with a Cryptic error message that shows up when i am trying to Delete images out of a Images field.
      The Error message does say a little but it does not make sense to me why i can´t delete the images because of it.

      Is it some permission issue perhaps?

      I will attach screenshots of it and what i did prior to it.
      I am from sweden so ignore the funny words here and there.

      Hope you all can send me on the right track.
      i am running PW 3.0.139 on this install.

      Step1:

      Step 2: Select the images with the trashcan symbol

       
      Step 3: Cryptic Error message

      I am scratching my head on this one, have not seen this before.

      Thankfull for all help.
      /EyeDentify
    • By Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  
      ---- INITIAL POST FROM 2019-05-25 ----
       
×
×
  • Create New...