Documentation
IPS_GetMediaIDByName
int IPS_GetMediaIDByName (string $MediaName, int $ParentID)
Parameters
| MediaName | Name of the searched media |
| ParentID | ID of the object whose children are searched for the media object |
Returns
ID of the found media object, otherwise FALSE
Description
The function tries to determine the ID of the media object called MediaName, whose parent has the ID ParentID. It will use the ID of the first found media object whose name matches MediaName. If such a media object was found, its ID is returned, otherwise the function returns FALSE.
This function utilizes an additional criterion (ParentID) which restricts the search to the children of one object. Thus, the probability to find the right ID is increased considerably. However:
As names within IP-Symcon are not unique it is possible that the function returns a wrong ID.
This function generates a warning if the name was not found. The @ operator can be used to suppress these messages. The exact functionality of this operator is found in the PHP manual.
Example
$MediaID = @IPS_GetMediaIDByName("MyPicture", 12345);
if ($MediaID === false)
echo "Picture not found!";
else
echo "The Media ID is: ". $MediaID;