-
-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
work with Wordpress UPLOADS constant #457
Conversation
enh: code refactor and cleanup bug: removed buggy 'require'
Hi @xavierpriour, thanks for the PR! There's a lot to go through, so it might take me a few days. To start us off can you take a look at resolving the errors in PHP 5.3?: https://travis-ci.org/jarednova/timber/builds/48849954 ... PHP 5.3 doesn't support accessing array properties from a method so... $path = wp_uploads_dir()['basedir']; Should become: $wp_uploads_dir = wp_uploads_dir();
$path = $wp_uploads_dir['basedir']; The other thing that would be very helpful is to provide a docblock for each new class you've added so I can make sure I understand the intent as I go through it. (This is something I want to do with existing classes too, but good to start somewhere). The WordPress docs have a little more background here. And a few others like that. Once that's clear I'll dive more |
Hi @jarednova, Thanks for the follow-up, I'll work on the class docs. On the PHP 5.3, any chance I could convince you to switch to requiring PHP On Fri, Feb 6, 2015 at 5:01 PM, Jared Novack notifications@github.com
Xavier Priour |
Just to jump in on the PHP version support, we're in a position of having to run RedHat Enterprise Linux 6 on our VMs. RHEL 6 packages PHP 5.3 (with security patch back ports as needed). While I really wish we were not tied to 5.3, it's the reality in our organization. I'm sure most people developing for Wordpress are not doing so under RHEL or other enterprise Linux (where packages are locked in for the long haul), but it's important to keep in mind that there are some of us. That and Wordpress still officially supports 5.2.4 or later (though they recommend 5.4 or later). https://wordpress.org/about/requirements/ |
Okay @jnweaver @jarednova - guess it has to be 5.3 then... Would you know of an (easy) way to setup a PHP 5.3 Timber test env? |
@xavierpriour there's some discussion here about switching PHP versions in VVV (conclusion: not a part of the software). So the best bet seems to be using Travis to report issues and fixing (and then pushing back to your branch to re-test). You can see the builds you submit listed here: https://travis-ci.org/jarednova/timber/pull_requests ... I've found that you can solve 99% of the problems with this: Arrays from methodsPHP 5.4$foo = get_my_bar()['foo']; PHP 5.3$bar = get_my_bar();
$foo = $bar['foo']; Declaring arraysPHP 5.4$foo = []; PHP 5.3
|
All done, build passing, thanks a lot for the 5.3 tips @jarednova |
@xavierpriour: The TimberImage functions feel SO MUCH BETTER. I did make some changes, mainly just separating each class into its own file. Once that was complete, I added some further docs and merged into master. I'm going to push this to WP.org next week. Thanks again! |
Glad I could help. I see you moved is_absolute to URLHelper, which is a great thing - you might want to move TimberImageHelper::is_external as well, while you're at it. Also, I realize the delete code is still in TimberImageHelper, while I believe it belongs in the TimberImageOperation classes (case in point, I think retina images are never deleted). Want me to submit a PR in that sense? |
Wordpress lets you define a custom uploads directory by setting the UPLOADS constant (http://codex.wordpress.org/Editing_wp-config.php#Moving_uploads_folder).
The existing implementation of "resize" did not take that case into account and generated incorrect URL for the files, resulting in broken img links.
To fix it, I rewrote the function, then also updated the other image manipulation filters (retina, img_to_jpg and letterbox) to handle that case as well.
In the end, I significantly refactored TimberImageHelper to focus on comprehensive directory handling, and moved image manipulation to dedicated class hierarchy (under TimberImageOperation).