Open felciano opened 12 years ago
I should clarify that part of the link rewriting is for embedded images, which is maybe what the "attachment ID" refers to. I've verified that these media are in the wordpress.com site and the URLs are correct. Is there any way to list out the "attachment IDs" that a post refers to?
WordPress gives more information in GetPost
than it expects in EditPost
, which is leading to this issue. I can handle it better in the library, and I'll try to do so in the next release.
In the meantime, you can try calling post.thumbnail = post.thumbnail['attachment_id']
before EditPost
. This will change it to the value expected by WordPress. Let me know if that doesn't work and I can dig deeper.
No luck -- still dumps out the same error. FWIW here is what post.thumbnail has before the assignment:
{
'attachment_id': '720',
'description': '',
'parent': 716,
'title': 'Chicco-KeyFit-Infant-Car-Seat-Limonata',
'date_created_gmt': <DateTime '20120521T19:15:47' at 2edaf80>,
'caption': '',
'link': 'http://minimalistmamatest.files.wordpress.com/2012/05/chicco-keyfit-infant-car-seat-limonata.jpg',
'thumbnail': 'http://minimalistmamatest.files.wordpress.com/2012/05/chicco-keyfit-infant-car-seat-limonata.jpg?w=150',
'metadata': {
'width': '500',
'hwstring_small': "height='96' width='106'",
'image_meta': {'shutter_speed': '0',
'copyright': '',
'caption': '',
'title': '',
'credit': '',
'created_timestamp': '0',
'camera': '',
'iso': '0',
'focal_length': '0',
'aperture': '0'
},
'file': '/home/wpcom/public_html/wp-content/blogs.dir/606/36648499/files/2012/05/chicco-keyfit-infant-car-seat-limonata.jpg',
'height': '451'
}
Are you intending to overwrite this dictionary with just the value of the attachment_id field (i.e. '720')?
Correct, thumbnail for EditPost
should just be the ID. Can you confirm in WordPress that a media item with ID=720 actually exists?
Unfortunately I won't have time to investigate this further until next week. Another alternative could be to just unset the thumbnail field (post.thumbnail = None
); WordPress should leave the existing thumbnail alone in that case.
I think the media looks right, although I'm not very familiar with that part of the API. The following prints the right name for the thumbnail ("Chicco-KeyFit-Infant-Car-Seat-Limonata"):
print post.thumbnail
print wp.call(GetMediaItem(post.thumbnail["attachment_id"]))
Part of the purpose of this script is to update links within posts that point to--or display--image media. The posts were exported from blog A and imported to blog B. Both blogs contain the necessary media, but the export/import process didn't update the links so the posts in blog B still display images from blog A. So I'm basically just renaming the links to point to the blog B media directory.
I'm not sure I understand how and when thumbnails are generated. Based on the above, does post.thumbnail = None
seem like a safe operation?
+1 on this issue
Triggered when calling EditPost on a post where a thumbnail exists. Setting post.thumbnail=post.thumbnail['attachment_id'] doesn't help.
@evandavey @felciano Hi guys, were either of you experiencing this issue in conjunction with @maxcutler's WordPress plugin?
Nope, this was all on Wordpress.com (hosted), so no special plugins.
@felciano @evandavey I believe this is the issue, I've attached a patch if you are still getting the "Invalid attachment ID" error.
just running into the same issue and the solution:
post.thumbnail = post.thumbnail['attachment_id'] before EditPost
did in fact fix the problem for me - Thanks!
+1 to fix from the code!
Thank you! using post.thumbnail = post.thumbnail['attachment_id'] helped!!
I am trying to use your library (v2.1) to write a script to replace broken links after a blog migration to Wordpress.com. After retrieving posts and making corrections to the post.body, I
Running this consistently yields this error, irrespective of the post in question or whether any changes were made:
Any suggestions?