Git Product home page Git Product logo

airani / wp-auto-upload Goto Github PK

View Code? Open in Web Editor NEW
78.0 10.0 40.0 827 KB

Automatically detect external images in the Wordpress post content and import images to your site and adding to the media library and finally replace image urls with new urls

Home Page: http://wordpress.org/plugins/auto-upload-images/

PHP 89.12% Shell 10.88%
wordpress wordpress-plugin php automation images upload import automatic image wp

wp-auto-upload's People

Contributors

a-custom avatar airani avatar diegoh avatar luvrei avatar onditorauib avatar tillz avatar zdanev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-auto-upload's Issues

WP MU

I use your great plugin for few years. Particularly it great for export/import blogs between domains. Now I tried it for WP Multi site installation and there are few problems.
First - sometimes it required few attempts for make plugin work correctly because at first attempt it return 500 error, but on second work correctly.
Error:
test.myblog.com page isn't working
test.myblog.com is currently unable to handle this request
500

Other thing is option that could be extremely helpful for WP MU - additional field to setup upload directory by user choice.
Let me explain. In MU installation even if I setup upload directory in wp-config all images uploads to /images/site/1/ which is "local" for each individual blog.
It would be great if it possible to add field in settings (and plugin functions) where user may specify path for images in root outside MU directories like home/myblogs/public_html/images/my_pictures/ - that would be priceless for multiple blogs as they can use same pictures across network instead of multiple uploads of the same pictures.

Thank you for your consideration.

Wordpress 5.0+ Gutenberg Compatibility

With Gutenberg posts (Wordpress 5.0+), updating a post does not upload any externally linked images. Publishing a post, the image will be uploaded, but the file name is occasionally missing from the src

Could you put ‘www.’ into the configuration?

public static function getHostUrl($url = null, $scheme = false)
    {
        $url = $url ?: WpAutoUpload::getOption('base_url');

        $urlParts = parse_url($url);

        if (array_key_exists('host', $urlParts) === false) {
            return null;
        }

        $url = array_key_exists('port', $urlParts) ? $urlParts['host'] . ":" . $urlParts['port'] : $urlParts['host'];
        $urlSimplified = preg_split('/^(www(2|3)?\.)/i', $url, -1, PREG_SPLIT_NO_EMPTY); // Delete www from URL
        $urlSimplified = is_array($urlSimplified) && array_key_exists(0, $urlSimplified) ? $urlSimplified[0] : $url;
        $url = $scheme && array_key_exists('scheme', $urlParts) ? $urlParts['scheme'] . '://www.' . $urlSimplified : $urlSimplified;

        return $url;
    }

Could you put ‘www.’ into the configuration?

Date on images saving

Although plugin is great, there is one problem - images dated at day it was saved.
Plugin works fine even in bulk posts edit - just selecting posts -> edit -> save - will save all pictures in selected posts... but with present date, not the date of the post. So saving images in old posts create a big chronological mess and finding pictures in media very difficult.

Is it possible to save pictures with date of post where pictures attached?

Replace <a href> to local image

In case <img> wrapped in <a href>:

<a href="https://google.com/full/7ai.png" target="_blank" rel="noopener"><img src="https://google.com/full/7ai.png" alt="" /></a>

after upload image need replace <a href> to local image.

Images were not imported into media-library after pasting form external site

I have created a new post and pasted the content incl. images from external resource.

By doing this I was expecting the images to be imported into media-library.

Instead the images are embedded as links to the external source.

Maybe I have not fully understood if this plugin supports this kind of workflow?

Updated Plugin: Error Occurs on Activation

Hi there,

I have loved this plugin for many years and updated to v3.1 yesterday only to find there seems to be an error. Perhaps it's just my setup, but activating the plugin causes the following error:

Plugin could not be activated because it triggered a fatal error.
Parse error: syntax error, unexpected '[' in .../wp-content/plugins/auto-upload-images/src/ImageUploader.php on line 37

Wordpress is up to date at 4.7.3

It seems to be an array calling [0] where the error is occurring.
I attempted to remove the [0] which fixed the error, but instead broke the upload URL.

I hope this can be fixed!

Save 2x with same pict

When Edit/ Update article;, plugin save 2x image (duplicate) give with different name.
can u fix it ?
or add some feature to not upload/save image when edit article

Improvement of URL matching

So I got multiple errors from ImageUploader::getFilename()

Some URL, like
https://lh3.googleusercontent.com/nFZVza6phshhw7VJ7-h2WP5Rrw1ASB1RV27pCDNXQYoIqmK-3pfL7BMCuQZ8mqfYf32ywCebbZdrtGCPHMOX6r1ZGy-_yPzcUkzykwYRqwA09cwLRfoxDJmaprQJyK6IUgWuYwuM
do not work with the function

I propose an improvement :
/** * Return custom image name with user rules * @return string Custom file name */ public function getFilename() { $filename = basename($this->url); if(preg_match('#(.+?)\?(.+[^.]*)$#', $filename, $name_parts)) { $this->filename = $name_parts[1]; $postfix = $name_parts[2]; if (preg_match('/^(\.[^?]*)\?.*/i', $postfix, $postfix_extra)) { $postfix = $postfix_extra[1]; } } else { $this->filename = $filename; $postfix = ''; } $filename = $this->resolvePattern(WpAutoUpload::getOption('image_name')); return $filename . $postfix; }

Note the change of regex from
/(.*)?(\.+[^.]*)$/
to
#(.+?)\?(.+[^.]*)$#

Image URL with filename that have multiple equal sign cause error

I have a site with Codecogs (as a math formula editor - LaTex editor).
For example, each formula imports from Codecogs will look like this:
<img src="https://latex.codecogs.com/gif.latex?|t|\leq&amp;space;1" alt="|t|\leq 1" align="absmiddle" />

My file name setting is: %timestamp%-%filename

Codecogs:
<img src="https://latex.codecogs.com/gif.latex?y=f(x)=\frac{g(x)}{h(x)}" alt="y=f(x)=\frac{g(x)}{h(x)}" align="absmiddle">

The plugin then change to local url, and it returns 404 Error.
<img src="https://abc.com/wp-content/uploads/2019/05/29_timestamp-filename.gif=\frac{g(x)}{h(x)}" alt="y=f(x)=\frac{g(x)}{h(x)}" align="absmiddle">

This URL https://abc.com/wp-content/uploads/2019/05/29_timestamp-filename.gif return a path of formula image: y = f(x) while the full formula is: y=f(x)=\frac{g(x)}{h(x)}

So I believed that the "=" characters cause the problem as the plugin think that it's over so it don't continue fetch the image any more?

Uploading bbpress external Images

The images in the bbpress forums upload, but the only way to get them to upload to the media library is to click on Dashboard>Topics>All Topics> Screen Options, set to 50 (any more than that returns errors), Highlight all> Edit> Update.

While this is okay for small boards, I just imported over 400K posts. Is there a way to force it to BULK Update automatically? It's really not feasible to manually edit 8,000 Times.

Not working with 4.8.2 with enabled "Image size" option

If max width and max height is set, path in posts is replaced with missing (image)filename.
This part is failing in return a valid filename:

    // if set max width and height resize image
     if (WpAutoUpload::getOption('max_width') || WpAutoUpload::getOption('max_height')) {
         $width = WpAutoUpload::getOption('max_width');
         $height = WpAutoUpload::getOption('max_height');
         $image_resized = image_make_intermediate_size($image_path, $width, $height);
         $image_url = urldecode($upload_dir['url'] . '/' . $image_resized['file']);
     }

About Auto Upload Image using in my server

Hi Ali Lrani,

i'm using you pluging , it's great and amazing !

but when i using in my server , i found some issue about PHP error ,

step 1 , intalled plugin
step 2 : edit the post
step 3 : if post has 3 image on the outside URL , i got Error "Fatal error: Call to undefined function mime_content_type() in /home/artmarry/public_html/website/circlewed/wp-content/plugins/auto-upload-images/src/ImageUploader.php on line 210"
step 4 : i'm trying edit again , got error again to the fourth time will be success import all image from outside.

i'm try to using other founction "finfo" , but still not work fine :(

May u help me ?

Improvement of post date management / upload folder

from wp.org

Right now, the plugin has trouble picking a folder, especially for draft/pending posts which do not have a post_date_gmt set.

Proposal :
Replace src/ImageUploader.php:161
$upload_dir = wp_upload_dir(date('Y/m', $this->post->post_date_gmt ? strtotime($this->post->post_date_gmt) : time()));
By :
if( get_option( 'uploads_use_yearmonth_folders' ) ) { if( strtotime( $this->post->post_date_gmt ) > 0 ) { $post_time = strtotime( $this->post->post_date_gmt ); } elseif( strtotime( $this->post->post_date ) > 0 ) { $post_time = strtotime( $this->post->post_date ); } else { $post_time = time(); } $upload_dir = wp_upload_dir( date( 'Y/m', $post_time ) ); } else { $upload_dir = wp_upload_dir(); }
This code respect the choice of using yearmonths folder, and tries to get the best possible date from the post

Download if post is published

I have a bunch of scheduled posts and I don't want it auto upload external images until the post becomes published. Is there a way to do this?

New features suggestions

Hey guys,

Great plugin! It would be great to see 2 features added to the plugin:

  1. A %timestamp% option in the filename to call time(); (unix timestamp). This is a great way of adding a unique string of numbers to the filename to avoid duplicate names if uploaded on the same day.
  2. Option to "set first image as featured image" option added to the plugin. This would be very useful for the people who remote publish photos to wordpress from IFTTT (eg. instagram or facebook photos). We need to set the featured image of the post to get correct thumbnails appearing when sharing links on social media.

Issue with Url have redirect

If image url start with http, but the target redirect to https, curl without CURLOPT_FOLLOWLOCATION set to true will return empty string.

please add : curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); to resolve this issue

Thank you

There is no option to remove or change original link of image.

I've copied a post from one site and pasted in my own. AS a result plugin downloaded all images as well but it kept all external links to the original site.

I didn't find any options to remove or change it from plugin settings.

Could you add this feature ?

Handle alt attribute

Is it possible to handle alt attributes and set it as caption, title or description?

Intel Logo

internal server error when creating a post thru JSON API

I create a post from a JSON API that has a single image tag inside the content. The image gets fetched and saved in the media library. The post gets created but the image name is not replaced with the local name. Internal Server Error is returned by the JSON API call.

Ends attachments with a .php extension

This works great, except for 1 major problem, it renames attachments ending them with a .php extension - if you click on an image within a post- it shows a page of scrambled coded.

If you try to save an image within a post, it saves as a .php

how do you make it save attachments as .jpg .png .gif files the way they were initially uploaded?

Not work with watermark plugins

خسته نباشید. افزنه بسیار خوبی است.
فقط یک مشکل دارد و ان هم با افزونه های واتر مارک کار نمی کند.
من به شخصه با افزونه های
Easy Watermark - Image Watermark
امتحان کردم که با هیچ کدوم کار نکرد.
لطفا این مشکل رو هم برطرف کنید تا بشه بصورت خودکار واتر مارک زد.

Support srcset attribute of img tag

Hi! Your plagin don't download images from srcset attribute.
https://www.w3schools.com/tags/att_source_srcset.asp
https://html.com/attributes/img-srcset/

Example:
<img class="aligncenter size-large wp-image-29" src="https://mysite.com/5ba585c425254.png" width="640" height="239" srcset="https://mysite.com/5ba585c425254.png 1024w, https://originsite.com/5ba585c425254-150x56.png 150w, https://originsite.com/5ba585c425254-300x112.png 300w, https://originsite.com/5ba585c425254-768x287.png 768w, https://originsite.com/5ba585c425254-640x239.png 640w, https://originsite.com/5ba585c425254-980x366.png 980w, https://originsite.com/EW5vYUlm9xuJnGOZBZN1F38Hw.png 1308w" sizes="(max-width: 640px) 100vw, 640px" />

Add support for HTTPS base URL

When your WordPress blog is working with HTTPS the plugin still uses HTTP urls, causing errors in the browser and of course undermining the security and HTTP/2 optimization.

Usable in theme files

Is it possible to use your plugin directly within theme files?

I've got a page which retrieves feeds from other pages. So I don't use the WordPress editor to save posts. Therefore it would be nice to call a function to replace / upload the images.

https и svg

Hi! Doesn’t work with pictures that are via https
It would be nice if I could take svg pictures
And also I could process not only <img src, but also background: url ('https: // .... Then all pictures would be processed

Doesn't work with Squarespace CDN URLs

Square space URLs have query arguments as part of the URL.

This is the format:

https://static1.squarespace.com/static/<md5>/t/<another md5>/<unix timestamp>/?format=original

This is a real example:

https://static1.squarespace.com/static/5810be5b6a4963badf51afb8/t/5cad58e39b747a554934692c/1555050634864/?format=original

Finding external images without using HTML

The plugin only finds the external images if they are embedded in img tags and have src and alt attributes. It would be very useful if there is also the possibility to find images without the img tags and src and alt attributes. For example, with the following regular expression '/ https?: \ / \ / [^] +? (?: \ .jpg | \ .png | \ .gif) / i'.

Unfortunately, I'm not good enough in PHP to implement this. It would be great to see this feature added to the plugin.

Not working with site imported from blogger

I have imported a site from blogger, and posts content is:

 <a style="margin-left: 1em; margin-right: 1em; text-align: center;" href="https://3.bp.blogspot.com/file.jpg"><img src="https://mydomain.org/wp-content/uploads/sites/00/file.jpg" width="640" height="480" border="0" data-original-height="1200" data-original-width="1600" /></a>

I tried scanning again but it is not working. The <img> tag has been corrected (I don't know if by your module or by import); but <a> of a .jpg isn't.
Shouldn't it work? I haven't set any size limit to auto upload.

Thanks

base64 insertion?

Using the plugin – I detected that the following code was being inserted into the post.
I see a reference to base64 on line 165 of ImageUploader.php – is it connected?

<span style=”border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; text-indent: 20px; width: auto; padding: 0px 4px 0px 0px; text-align: centre; font-style: normal; font-variant-caps: normal; font-weight: bold; font-size: 11px; line-height: 20px; font-family: ‘Helvetica Neue’, Helvetica, sans-serif; color: #ffffff; background-image: url(data:image/svg+xml; base64,phn2zyb4bwxucz0iahr0cdovl3d3dy53my5vcmcvmjawmc9zdmciighlawdodd0imzbwecigd2lkdgg9ijmwchgiihzpzxdcb3g9ii0xic0xidmxidmxij48zz48cgf0acbkpsjnmjkundq5lde0ljy2mibdmjkundq5ldiyljcymiaymi44njgsmjkumju2ide0ljc1ldi5lji1nibdni42mzismjkumju2idaumduxldiyljcymiawlja1mswxnc42njigqzaumduxldyunjaxidyunjmyldaumdy3ide0ljc1ldaumdy3iemymi44njgsmc4wnjcgmjkundq5ldyunjaxidi5ljq0oswxnc42njiiigzpbgw9iinmzmyiihn0cm9rzt0ii2zmziigc3ryb2tllxdpzhropsixij48l3bhdgg+phbhdgggzd0itte0ljczmywxljy4nibdny41mtysms42odygms42njusny40otugms42njusmtqunjyyiemxljy2nswymc4xntkgns4xmdksmjquodu0idkuotcsmjyunzq0iem5ljg1niwyns43mtggos43ntmsmjqumtqzidewljaxniwymy4wmjigqzewlji1mywymi4wmsaxms41ndgsmtyuntcyidexlju0ocwxni41nzigqzexlju0ocwxni41nzigmteumtu3lde1ljc5nsaxms4xntcsmtqunjq2iemxms4xntcsmtiuodqyideyljixmswxms40otugmtmuntiyldexljq5nsbdmtqunjm3ldexljq5nsaxns4xnzusmtiumzi2ide1lje3nswxmy4zmjmgqze1lje3nswxnc40mzygmtqundyylde2ljegmtqumdkzlde3ljy0mybdmtmunzg1lde4ljkznsaxnc43ndusmtkuotg4ide2ljayocwxos45odggqze4ljm1mswxos45odggmjaumtm2lde3lju1niaymc4xmzysmtqumdq2iemymc4xmzysmtauotm5ide3ljg4ocw4ljc2nyaxnc42nzgsoc43njcgqzewljk1osw4ljc2nya4ljc3nywxms41mzygoc43nzcsmtqumzk4iem4ljc3nywxns41mtmgos4ymswxni43mdkgos43ndksmtcumzu5iem5ljg1niwxny40odggos44nzismtcunia5ljg0lde3ljczmsbdos43ndesmtgumtqxidkuntismtkumdizidkundc3lde5ljiwmybdos40miwxos40nca5lji4ocwxos40otegos4wncwxos4znzygqzcunda4lde4ljyymia2ljm4nywxni4yntigni4zodcsmtqumzq5iem2ljm4nywxmc4yntygos4zodmsni40otcgmtuumdiyldyundk3iemxos41ntusni40otcgmjmumdc4ldkunza1idizlja3ocwxmy45otegqzizlja3ocwxoc40njmgmjaumjm5ldiylja2miaxni4yotcsmjiumdyyiemxnc45nzmsmjiumdyyidezljcyocwyms4znzkgmtmumzayldiwlju3mibdmtmumzayldiwlju3miaxmi42ndcsmjmumdugmtiundg4ldizljy1nybdmtiumtkzldi0ljc4ncaxms4zotysmjyumtk2idewljg2mywyny4wntggqzeylja4niwyny40mzqgmtmumzg2ldi3ljyznyaxnc43mzmsmjcunjm3iemyms45nswyny42mzcgmjcuodaxldixljgyocayny44mdesmtqunjyyiemyny44mdesny40otugmjeuotusms42odygmtqunzmzldeunjg2iibmawxspsijymqwodfjij48l3bhdgg+pc9npjwvc3znpg==); background-size: 14px 14px; background-color: #bd081c; position: absolute; opacity: 1; z-index: 8675309; display: none; cursor: pointer; border: none; -webkit-font-smoothing: antialiased; background-position: 3px 50%; background-repeat: no-repeat no-repeat;”>Save

I did the usual troubleshoot, switch all plugins off, built everything up 1 x 1.

https not work?

В моём посте есть несколько картинок с сайтов https.
Не работает(((
Но с http всё работает отлично)

In my post there are a few pictures from https.
 Does not work(((
But with http everything works fine)

Videos

Is there a way to get this to work with videos too?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.