I have an architectural floor plan that I would like to add buttons to that open/close different elevations (pics) throughout the project. I want each button to open/close its own corresponding picture.
You have everything you need above. You just need to change the field name, between the quotes.
To make it a bit more compact, and so that you only have to enter the field name once, use this version of that code:
// Change "Picture_af_image" below to the name of your actual field
var imageFieldName = "Picture_af_image";
var f = this.getField(imageFieldName);
if(f.display == display.visible)
f.display = display.hidden;
else f.display = display.visible;