Gallery Images¶
Low-level functions for reading and writing listing image post meta. For rich image data (src, dimensions, alt, caption) use the methods on the Listing object instead (get_main_image(), get_gallery_images()).
Functions¶
dms_get_main_image( int $listing_id ): int|bool¶
Returns the attachment ID of the listing's main (featured) image. Returns false if none is set.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$listing_id |
int |
- | The listing post ID |
Returns - int\|bool
Example
$image_id = dms_get_main_image( 42 );
if ( $image_id ) {
$src = wp_get_attachment_image_url( $image_id, 'full' );
}
dms_set_main_image( int $listing_id, int $image_id ): int|bool¶
Sets the main (featured) image for a listing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$listing_id |
int |
- | The listing post ID |
$image_id |
int |
- | The attachment ID to set as main image |
Returns - int\|bool - result of update_post_meta()
Example
dms_remove_main_image( int $listing_id ): bool¶
Removes the main image assignment from a listing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$listing_id |
int |
- | The listing post ID |
Returns - bool
Example
dms_set_gallery_images( int $listing_id, string $gallery_images ): int|bool¶
Stores the gallery image data string in post meta. This is a raw setter - for managed gallery operations use the DMS admin UI or the Listing object methods.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$listing_id |
int |
- | The listing post ID |
$gallery_images |
string |
- | Serialized gallery image data |
Returns - int\|bool - result of update_post_meta()
Example
dms_remove_gallery_images( int $listing_id ): bool¶
Removes all gallery image data from a listing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$listing_id |
int |
- | The listing post ID |
Returns - bool
Example