Loading and Referencing Images
I’m slowly writing a page to manage an asset database; effectively, writing a very basic plugin. I want to import photos and found some excellent examples of how to do this and, made it work! My problem then was to display the images in the page. Although I know the uploaded image filename, there seems to be no way to use it. The image will be put into the current ‘date’ folder and could well be renamed on the way. I’ve ended up querying the last post ID just before I import the image and adding 1 to it to reference the image. With the post ID I can then use wp_get_attachment_image_src to get a url for the (resized) image: wp_get_attachment_image_src( $result->PostNum, ‘medium_large’ )
It works but it is very clunky. Is there a better way of doing this?
Leave an answer