Skip to content

Update CMB2_Utils.php - #453

Closed
wpscholar wants to merge 2 commits into
CMB2:masterfrom
wpscholar:patch-1
Closed

Update CMB2_Utils.php#453
wpscholar wants to merge 2 commits into
CMB2:masterfrom
wpscholar:patch-1

Conversation

@wpscholar

Copy link
Copy Markdown
Contributor

After having done a decent amount of research and testing on properly fetching an image ID from a URL, I've found this solution to be more robust. Ultimately, using the guid just isn't reliable enough: http://wpscholar.com/blog/get-attachment-id-from-wp-image-url/

After having done a decent amount of research and testing on properly fetching an image ID from a URL, I've found this solution to be more robust. Ultimately, using the guid just isn't reliable enough: http://wpscholar.com/blog/get-attachment-id-from-wp-image-url/
Correct URL reference
@jtsternberg

Copy link
Copy Markdown
Member

This looks good. The image_id_from_url method is actually a backup method in case the image ID didn't get properly saved to the hidden field. Are you seeing it fall back to this method often?

@wpscholar

Copy link
Copy Markdown
ContributorAuthor

@jtsternberg I was actually just perusing the code and noticed this. Knowing that the guid isn't the most reliable way, I figured I would throw in my two cents.

@jtsternberg

Copy link
Copy Markdown
Member

Had to fix my broken tests before I could merge your changes in, but got them in. This is merged into trunk: https://github.com/WebDevStudios/CMB2/commits/trunk

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wpscholar@jtsternberg