Skip Navigation

[Resolved] Update the media library for a new location of an uploaded image (custom field)

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 3 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1601213

Hi,
I have a custom filed of an image in a post type.

On cred_save_data I am moving this image to a custom folder (for example to newpath)
after that, the media library shows an empty image instead of the real image.

I found that I have to update the location of the image through the
update_attached_file( $attachment_id, "nepath" );

my question I how I get the &attachment_id of this custom image toolset field ;

thank you

#1602223

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

If your goal is to get the attachment ID using the attachment URL ( that is saved in the image type custom field ), you can use the "attachment_url_to_postid" function from WordPress:
https://developer.wordpress.org/reference/functions/attachment_url_to_postid/

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.