• Resolved Denis ?oljom

    (@dingo_d)


    I posted the question on the WPSE, but no answer so far: https://wordpress.stackexchange.com/questions/299696/how-to-find-out-where-the-data-model-is

    I am trying to figure out why the URL of my media library items isn’t matching what is in the database, so I went to search where this data comes from. So I opened wp-includes/media-template.php and saw that this is basically a bunch of underscores templates (yay /s).

    So I have

    <label class="setting" data-setting="url">
        <span class="name"><?php _e('URL'); ?></span>
        <input type="text" value="{{ data.url }}" readonly />
    </label>

    But where is data defined?

    • This topic was modified 6 years, 11 months ago by Denis ?oljom.
    • This topic was modified 6 years, 11 months ago by Denis ?oljom.
Viewing 7 replies - 1 through 7 (of 7 total)
  • What makes you think the data variable is especially relevant? Do you also get the incorrect URL when using wp_get_attachment_url() for the given attachment ID? Or is it only incorrect in the Media Library details view?

    Thread Starter Denis ?oljom

    (@dingo_d)

    Yes, the URLs point to the local files and the URLs in the database point to my amazon s3 bucket. I’m using S3-Uploads to upload to the bucket and use images from the bucket instead of images on the local server.

    I’m using ACF to build content, and when I try to add an image to my content it adds the image with the URL of the local server instead of the bucket.

    It sounds like your problem is with ACF. Did you try what I said about wp_get_attachment_url(). What was the result of that?

    Thread Starter Denis ?oljom

    (@dingo_d)

    The URL appears in the media library. This cannot be the fault of the ACF.

    I’ll try with the function, but I reckon I’ll get the URL from the media library, and not from the database.

    Thread Starter Denis ?oljom

    (@dingo_d)

    @jakept When I tried to get the url using wp_get_attachment_url() I get the server url instead of the bucket (serverurl.com/wp-content/uploads/2018/…). And when I query the database with

    wp db query "SELECT * FROM devport_posts WHERE post_type = 'attachment'"
    

    the guid is the s3 bucket.

    This is what is confusing me. Why are those two different?

    Nowhere in the database can I find the server url for attachments. Only the one of the bucket. I used HumanMade’s S3-Uploads plugin (https://github.com/humanmade/S3-Uploads) to upload files to bucket. And the credentials and everything seems to be working.

    • This reply was modified 6 years, 11 months ago by Denis ?oljom.
    • This reply was modified 6 years, 11 months ago by Denis ?oljom.

    Right, so the underscore template isn’t doing anything unusual on its own. WordPress’s core functions for getting attachment URLs is the same site-wide.

    The first thing to know is that the guid is completely irrelevant to where the image URLs come from. The GUID is merely a unique identifier that is created for posts when they are added to the database, primarily so that RSS readers have a way to identify which feed items are the same. The URL used is the URL at the time of creation and does not change, and WordPress never uses it as the URL for actually loading images (it does that through a combination of the _wp_attached_file meta value and the defined content directory for the site, which S3 Uploads likely modifies). See this article for more on GUIDs in WordPress.

    So really this just comes down to the S3 Uploads plugin apparently not working as expected. All I can suggest in that case is referring to documentation on GitHub and making sure everything is configured properly. HumanMade doesn’t appear to explicitly offer support for the plugin, but if you believe there’s a bug, you could report an issue on GitHub.

    Thread Starter Denis ?oljom

    (@dingo_d)

    Interesting, I wasn’t aware that the file location is stored as a relative path in the postmeta as _wp_attachment_metadata and _wp_attached_file. So the plugin is at fault somehow in the end.

    I’ll ask them what could cause that.

    Thanks for the help!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Where is data.model coming from?’ is closed to new replies.