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
      TrelloWire
      This is a module that allows you to automatically create Trello cards for ProcessWire pages and update them when the pages are updated. This allows you to setup connected workflows. Card properties and change handling behaviour can be customized through the extensive module configuration. Every action the module performs is hookable, so you can modify when and how cards are created as much as you need to. The module also contains an API-component that makes it easy to make requests to the Trello API and build your own connected ProcessWire-Trello workflows.
      Features
      All the things the module can do for you without any custom code: Create a new card on Trello whenever a page is added or published (you can select applicable templates). Configure the target board, target list, name and description for new cards. Add default labels and checklists to the card. Update the card whenever the page is updated (optional). When the status of the card changes (published / unpublished, hidden / unhidden, trashed / restored or deleted), move the card to a different list or archive or delete it (configurable). You can extend this through hooks in many ways: Modifiy when and how cards are created. Modify the card properties (Target board & list, title, description, et c.) before they are sent to Trello. Create your own workflows by utilizing an API helper class with many convenient utility methods to access the Trello API directly. Feedback & Future Plans
      Let me know what you think! In particular:
      If you find any bugs report them here or on Github, I'll try to fix them. This module was born out of a use-case for a client project where we manage new form submissions through Trello. I'm not sure how many use-cases there are for this module. If you do use it, tell me about it! The Trello API is pretty extensive, I'll try to add some more helper methods to the TrelloWireApi class (let me know if you need anything in particular). I'll think about how the module can support different workflows that include Twig – talk to me if you have a use-case! Next steps could be a dashboard to manage pages that are connected to a Trello card, or a new section in the settings tab to manage the Trello connection. But it depends on whether there is any interest in this 🙂 Links
      Repository on Github Complete module documentation (getting started, configuration & API documentation) [Module directory pending approval] Module configuration

    • 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
×
×
  • Create New...