Giter Club home page Giter Club logo

be-media-from-production's People

Contributors

billerickson avatar cliffordp avatar damiencarbery avatar dmytro-kovalov avatar graylaurenm avatar jonschr avatar rosswintle avatar szepeviktor 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  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  avatar  avatar  avatar

be-media-from-production's Issues

Provide filter for filtering the image url.

When switching from a default WordPress installation to a Bedrock based WordPress install or vice versa, the upload folder location changes. It would be nice if there would be a filter in the update_image_url() method where you can filter the image path.

Then things like this are possible.

add_filter(
	'be_media_from_production_image_url',
	function ($image_url) {

		return str_replace("/app/", "/wp-content/", $image_url);
	}
);

let me know your thoughts.

Add Changelog to Readme.txt for WP.org Repo

The v1.7.0 update didn't seem to have any changelog in the repo. I recall there previously was one, though I didn't go digging for it. It would be great to get that updated, especially to clarify the new branding/plugin co-owner.

Thanks for the great plugin!

Not working for a cover block

WordPress 5.4.2. Plugin 1.6.0.

I have a cover block with the following content stored in the database (I've changed the url for privacy):
(I disabled the comments so that they show here)
<! -- wp:cover {"url":"https://staging.example.com/wp-content/uploads/2020/08/bar-mitzvah-israel.jpg","id":7879} -- > &lt;div class="wp-block-cover has-background-dim" style="background-image:url(https://staging.example.com/wp-content/uploads/2020/08/bar-mitzvah-israel.jpg)"&gt;&lt;div class="wp-block-cover__inner-container"&gt;<! -- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -- > &lt;p class="has-text-align-center has-large-font-size"&gt;This image is from the staging site.&lt;/p&gt; <! -- /wp:paragraph -- >&lt;/div&gt;&lt;/div&gt; <! -- /wp:cover -- >

The file has been uploaded to the staging site only. It is not on the production site.

I added some error_log() calls to the local_filename() function.
function local_filename( $url ) { error_log( "local_filename: url = " . $url ); $upload_locations = wp_upload_dir(); error_log( "upload_locations: " . var_export($upload_locations, true) ); $local_filename = str_replace( $upload_locations[ 'baseurl' ], $upload_locations[ 'basedir' ], $url ); error_log( "local_filename: return = " . $local_filename ); return $local_filename; }
and this is what I see in the debug.log file:
[05-Aug-2020 21:24:32 UTC] local_filename: url = https://staging.example.com/wp-content/uploads/2020/08/bar-mitzvah-israel.jpg) [05-Aug-2020 21:24:32 UTC] upload_locations: array ( 'path' => '/home/example/staging.example.com/wp-content/uploads/2020/08', 'url' => 'https://staging.example.com/wp-content/uploads/2020/08', 'subdir' => '/2020/08', 'basedir' => '/home/example/staging.example.com/wp-content/uploads', 'baseurl' => 'https://staging.example.com/wp-content/uploads', 'error' => false, ) [05-Aug-2020 21:24:32 UTC] local_filename: return = /home/example/staging.example.com/wp-content/uploads/2020/08/bar-mitzvah-israel.jpg)

It seems to be doing the right substitution but note that the incoming $url has a closing round bracket at the end.
This appears to be from the background-image style.

Is this a possible bug in the cover block's rendering code?
Do you have any ideas where would I look for that?

uploading images while on local

Does this make it that uploading images goes to the server and not the local?
Or it just shows images already in the system as remote?

We are using a remote DB and are trying to find a way that if a dev uploads via the local url it gets added to the production server.

Consider adding documentation for getting media from sites behind HTTP Auth

I'm currently using this plugin on a site where I need to use media from a staging site that is behind HTTP Auth (i.e., the little popup browser window that asks for a username and password).

I was pleased to figure out that you can make this work with this plugin as-is list this:

https://user:[email protected]

That gets you the media from example.org where the auth username is "user" and the password is "password".

It seems like this might be worth quickly documenting (maybe in a FAQ in the readme)? Happy to submit a PR if you'd like :)

Doesn't work if uploads aren't in wp-content/uploads

First of all, thanks for the awesome plugin. So helpful.

I've installed this on a new client's site where I'm taking over support of an existing site where the old developer has gone away.

The old developer has a bit of an odd wp-config.php and one of the things it does is:

define('WP_CONTENT_URL', "http://{$_SERVER['SERVER_NAME']}");

and his directory structure reflects this.

BE-Media-from-Production doesn't work in this setup.

At the very least, line 196 reads:

if( strpos( $url, 'wp-content/uploads' ) ) {

and should probably be changed so that it matches the WP_CONTENT_URL

if( false !== strpos( $url, WP_CONTENT_URL . '/uploads' ) ) {

(Note that we could now get a 0 from strpos and so we need the type-specific comparison)

You may also want to test for, and use if necessary, the UPLOADS constant (though, unlike WP_CONTENT_URL, this doesn't seem to be set by default, and will need to be tested for)

Local image exists check fails for local images' srcset attribute

If an image exists locally and is output with a srcset attribute, it fails the local_image_exists check, so the plugin replaces the URLs in the srcset with the production URL.

It looks like this is because the [image_attr](https://github.com/billerickson/BE-Media-from-Production/blob/master/be-media-from-production.php#L156) method passes the srcset value to the image updater, but the local image check is expecting a URL, and the srcset will be a string such as:

http://local.example.test/wp-content/uploads/2019/05/tim-foster-264461.jpg 4599w, http://local.example.test/wp-content/uploads/2019/05/tim-foster-264461-300x206.jpg 300w, http://local.example.test/wp-content/uploads/2019/05/tim-foster-264461-768x526.jpg 768w, http://local.example.test/wp-content/uploads/2019/05/tim-foster-264461-1024x702.jpg 1024w

which will not return true for the file existing.

Actually, I think all that needs to happen is to change line 159 to this:

$attr['srcset'] = $this->update_image_url( $attr['src'] );

(passing just src to the updater instead of srcset... this fixed the issue for me locally.

Non-image urls

Love this functionality. I'm installing it on a number of sites, and this is going to let me not have to maintain so much space on my tiny little mac for larger sites.

I wonder if it would be possible to add functionality for the wp_get_attachment_url function in addition to the ones already supported (wp_get_attachment_image_src, wp_get_attachment_image_attributes, wp_prepare_attachment_for_js, the_content); this obviously could be used for images, but my use case is actually video files that we're pulling in via ACF to add background video.

This is how it's being pulled in currently:

https://gist.github.com/jonschr/224d56a40c9f7e5931355a65018e1b44

Add composer file or upload in WP repository?

Hi Bill,

I love the plugin and almost use it in every project. We all love automating things such as plugin installs. Many will use composer and wpackagist to include plugins in our projects. But then the plugin has to be in the main WP repository. Is that something you are planning on doing? Another option would be to add an composer file to this repository so we could use something like:

composer config repositories.repo-name vcs https://github.com/billerickson/BE-Media-from-Production composer require billerickson/BE-Media-from-Production:master

This is needed for compsoser to work because right now composer trows an error:

[Composer\Repository\InvalidRepositoryException] No valid composer.json was found in any branch or tag of https://github.com/billerickson/BE-Media-from-Production, could not load a package from it.

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.