Project

General

Profile

Bug #2677

Broken File names due to repointing of preludenyc.org

Added by Kimon Keramidas over 8 years ago. Updated about 7 years ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
WordPress (misc)
Target version:
Start date:
2013-07-17
Due date:
% Done:

0%

Estimated time:

Description

In moving preludenyc.org to point to a new commons blog, all of the images on preludenyc12.commons.gc.cuny.edu have broken. It seems to be because when they were inserted they were given the domain of preludenyc.org like this: http://preludenyc.org/files/2012/09/Mac-Wellman.jpg. But that no longer works and the address should read http://preludenyc12.commons.gc.cuny.edu.org/files/2012/09/Mac-Wellman.jpg, which makes them work. We can go back and fix links manually, but this seems like it will be a problem that we will have to deal with every year and one that hopefully has an alternative solution.

Sorry to be creating such a stream of issues on Redmine. Thanks for all your help.

prelude13.zip (5.58 MB) prelude13.zip Theme for Prelude 13 Alex Hills, 2014-07-29 12:48 PM
prelude12.zip (6.22 MB) prelude12.zip Theme for Prelude 12 Alex Hills, 2014-07-29 12:48 PM

History

#1 Updated by Matt Gold over 8 years ago

  • Status changed from New to Assigned
  • Assignee set to Boone Gorges

No worries about the issue, Kimon -- that's what this site is here for! Thanks for developing actively on the Commons!

#2 Updated by Kimon Keramidas over 8 years ago

Thanks Matt

One note, I have fixed a couple of the images as a test for a manual correction, so if you go to look at the site to see the errors and an artist/event looks fine, just keep looking and you're sure to find a broken one.

In fact, here is an example of a broken one: http://preludenyc12.commons.gc.cuny.edu/event/hannahbos2/
Here is a manually corrected one: http://preludenyc12.commons.gc.cuny.edu/event/miguel-gutierrez-and-the-powerful-people/

By the way, galleries oddly enough work fine.

#3 Updated by Boone Gorges over 8 years ago

  • Status changed from Assigned to Reporter Feedback
  • Target version set to Not tracked

Given that you plan to make the URL swap every year, your best bet is probably to make the URLs relative rather than absolute. Eg, <img src="/files/2012/09/TS-31.jpg"> instead of the complete URL. When you add images with the WP "Add Media" button, it'll use the absolute URLs, so you'd have to manually modify the markup after adding the pictures.

Alternatively, you could consider not changing the URL every year, and just making the preludenyc.org URL into a redirect to the CAC URL. Not as pretty, to be sure, but it avoids this problem (and also the issue that it's bad practice to change a resource's URI, breaking incoming links).

What do you think?

#4 Updated by Kimon Keramidas over 8 years ago

Yeah I think that we will just have to deploy an intern each year we make the switch to change the source and link URIs in the Text view of each edit page.

The remaining question is why is it choosing preludenyc.org for the individual images, but creating correct links using preludenyc12.commons.gc.cuny.edy for galleries and even for the shadowbox effect? Is that something that could be changed so that it works for the Add Media button as it does in other places of the site. Here is a gallery that I have done nothing to that works fine after the change: http://preludenyc12.commons.gc.cuny.edu/event/avant-cabaret-spectacular/

I get the bad practice of changing the URI, but it is the sharpest way of directing traffic every year to the right place and getting clean URLs. What your suggesting is that you enter preludnyc.org and then you end up at preludenyc12.commons.gc.cuny.edu and all the subsequent URLs while travelling through the site have the long name, correct? If that is what you are saying it is something I could ask Frank and Rebecca.

#5 Updated by Boone Gorges over 8 years ago

The remaining question is why is it choosing preludenyc.org for the individual images, but creating correct links using preludenyc12.commons.gc.cuny.edy for galleries and even for the shadowbox effect?

I'd have to look more in-depth, but I'm guessing it's because the links for the shadowbox, etc are created programatically (so that WP, and in particular the domain mapping plugin, have a chance to intercept and rewrite the URLs on the fly). The images themselves have their URLs saved in two places: (1) in the src attribute of img tags, as stored in the content of the posts in the database, which would not be changed by the domain mapping plugin, and (2) in metadata attached to the attachment object in the database at the time the image is first uploaded (when the URL is preludenyc2012...), so that it doesn't have to be recreated every time the page is loaded.

What your suggesting is that you enter preludnyc.org and then you end up at preludenyc12.commons.gc.cuny.edu and all the subsequent URLs while travelling through the site have the long name, correct?

Yes, that's what I suggested above. I get why you might not like that, but you might at least want to consider it, as it'd automatically solve all these issues.

#6 Updated by Boone Gorges over 7 years ago

  • Category name set to WordPress (misc)

Hi Kimon - Just looking through some old outstanding tickets, and thought I'd circle back around to this one, especially as we may be coming up on another year's Prelude site. Do you have any thoughts on the above discussion? Another thought I had in rereading is that you could put a generic filter on 'the_content' that would catch most instances of the problem:

function preludenyc_filter_urls( $content ) {
    return str_replace( 'http://preludenyc12.commons.gc.cuny.edu', 'http://preludenyc.org', $content );
}
add_filter( 'the_content', 'preludenyc_filter_urls' );

and so on, for any URLs that are stored in the content of posts.

#7 Updated by Kimon Keramidas over 7 years ago

Ooh, I like that. That would be nice, because we can just change the year and use it for each year's different theme. Let me add it to the theme and send you a new version and see if works. Thanks for thinking of this.

#8 Updated by Kimon Keramidas over 7 years ago

One other thing about this bug Boone. When I created the 2013 Prelude site I mistakenly called it preludenyc2013.commons.gc.cuny.edu instead of preludenyc13.commons.gc.cuny.edu. Is there anyway to change a site's URL within the Commons after creation? I think we are going to go back to the two digit iteration.

#9 Updated by Boone Gorges over 7 years ago

There's no way to change a site's URL in the interface, but I can do it directly in the database. Note that it will break any incoming links to your site (that is, prelufenyc2013... will no longer resolve). If this is something you want to pursue, just let me know.

#10 Updated by Alex Hills about 7 years ago

Hey Boone,

Kimon implemented this url rewrite on Prelude 2012 and 2013 and we noticed that the urls should actually be flipped in the function. Currently, it's rewriting everything to preludenyc.org. You can see an example of the incorrect urls here: http://preludenyc12.commons.gc.cuny.edu/about/

I've attached a new zip file for each theme. The only change for both is switching urls in the functions.

Any chance we might be able to get this into the August 1 update? Thanks so much.

– Alex

#11 Updated by Boone Gorges about 7 years ago

  • Status changed from Reporter Feedback to Assigned
  • Target version changed from Not tracked to 1.6.11

No problem - I'll include this in the next update. Thanks, Alex.

Also available in: Atom PDF