Working with a WordPress site…

Working with a WordPress site where you have a lot of hardcoded image URLs, but the actual images aren’t in your repository.

One way to deal with the broken images is to use an nginx rule to rewrite the images url to a remote staging site.

Here’s my nginx configuration file, located at vagrant/www/{my-site}/provision/vvv-nginx.conf.tmpl:

server {
    listen       80;
    listen       443 ssl;
    server_name  {{DOMAINS_HERE}};
    root         {vvv_path_to_site}/public_html;

    error_log    {vvv_path_to_site}/log/error.log;
    access_log   {vvv_path_to_site}/log/access.log;

    set          $upstream {upstream};

    include      /etc/nginx/nginx-wp-common.conf;

	location ~* \.(gif|jpg|jpeg|png)$ {
		if ($uri ~ "^/wp-content/uploads/[^/]*/.*$"){
			set $rule_0 1$rule_0;
		}
		if ($rule_0 = "1"){
			rewrite ^/(.*)$ https://ecorner-staging.tcg.stanford.edu/$1 last;
		}
	}
}

Note that the .tmpl file is used rather than the .conf file, and that the `location` block is within the server block.

Sources:
https://varyingvagrantvagrants.org/docs/en-US/adding-a-new-site/custom-public_html/
https://github.com/Varying-Vagrant-Vagrants/VVV/issues/244
https://css-tricks.com/develop-locally-use-images-production/

Advertisements

Every company needs it’s own…

Every company needs it’s own special VVV configuration, and so far, it’s been a bitch to set it up every time. However, I succeeded, after several hours. Tom J Nowell helped me out with the last detail – https://github.com/Varying-Vagrant-Vagrants/VVV/issues/1390

https://make.wordpress.org/core/handbook/tutorials/installing-a-local-server/installing-vvv/

First day at 10up.com. As…

First day at 10up.com. As usual, there’s a lot of software to install. First is Thunderbird, so I can enjoy a nice separation between work and personal email.

Next, pritunnel for vpn’ing.

Git is hard

I keep on coming back to this SO answer:

How to check out a remote branc: https://stackoverflow.com/questions/1783405/how-do-i-check-out-a-remote-git-branch

Get urls out of href

href="([a-z:\/.0-9\-]*)"

#regex

Strip classes out of html

class="([a-z\-0-9\s]*)"

#regex

Slurp up all text between two tags

<footer class="entry-footer">(\s*.*\s*)<\/footer>

#regex