Page 1 of 1

Media order when gedcom imported

Posted: 11 Oct 2019 13:11
by pmolnar
Hi All,

I have an issue with persons' primary photo (photo order) after importing a tree from a gedcom file.

As you can see in the attached screenshot, the person has 5 photos, and the primary is the marked one with _PRIM.
This photo is on the fifth place in the person's photo list in FH and it displays the first photo as primary for the record.

Is there any trick, query or plugin that I can run to "fix" the photo order meaning putting the photo marked with _PRIM to the top of the photo list as primary photo.

Thanks,
Peter

Re: Media order when gedcom imported

Posted: 11 Oct 2019 13:23
by LornaCraig
Select the primary picture and then click the black upward arrow in the main toolbar to move it to the top of the list.
Main toolbar.JPG
Main toolbar.JPG (10.6 KiB) Viewed 6310 times

Alternatively, go to the Media tab of the individual's Property Box and use the arrows in the toolbar in the centre of that tab to change the order of the pictures.

Media tab toolbarJPG.JPG
Media tab toolbarJPG.JPG (18.2 KiB) Viewed 6310 times

Re: Media order when gedcom imported

Posted: 11 Oct 2019 13:25
by Jane
_PRIM is a UDF field, but you could write a plugin to move the one with the _PRIM udf field to the top of the list.

Re: Media order when gedcom imported

Posted: 11 Oct 2019 15:15
by tatewise
If it only affects a few Individuals then use Lorna's manual method.

It is only worth writing a Plugin if there are a great many.
The _PRIM UDF tag is used by several products, but is NOT standard GEDCOM, so not recognised by FH.
It should be deleted from your FH Project as explained in how_to:handling_unrecognised_data_fields|> Handling Uncategorised Data Fields (UDF).

Re: Media order when gedcom imported

Posted: 11 Oct 2019 17:29
by pmolnar
Thank you all for the reply. I have relatively big tree so I try to make some coding to have the expected result.

Could you please suggest some already existing plugins that do similar so that I don't need to start it from scratch?

Re: Media order when gedcom imported

Posted: 12 Oct 2019 04:48
by pmolnar
Ok, I started to work on it, but I need some help.

I try to find the right pointer to the list of assigned photo's list but I am not sure what would be the correct way:

I tried several path, finally I managed to find this one which returned something apparently right data:

ptrMedia = fhGetItemPtr(pi,'INDI.OBJE')

In this variable I can see the path of my photos if I index it (OBJE[x]), but I cannot get any other property of them, I am not sure this is the correct path.

Also, I tried to overwrite the data like this:
ptrMedia1 = fhGetItemPtr(pi,'INDI.OBJE[1]')
ptrMedia2 = fhGetItemPtr(pi,'INDI.OBJE[2]')
ptrMedia2 = ptrMedia1

Nothing happened, the photos assigned to the person didn't change at all, everything remained unchanged.

Re: Media order when gedcom imported

Posted: 12 Oct 2019 08:16
by Jane
I'll give you a couple of pointers.

To identify the item with the _PRIM tag once you have the obje item use a new pointer to check for the existence of the flag

I would loop through the objects catch the first one to a pointer and then when you find the one with the marker move it above the first one.

eg
ptrObjFirst = fhGetItemPtr(pi,'~.OBJE[1]')
ptrObj = fhGetItemPtr(pi,'~.OBJE')
ptrPrim = fhGetItemPtr(ptrObj,'~._PRIM')

To move the Obj above the first one use
bOK = fhMoveItemBefore(ptrObj,ptrObjFirst)

Re: Media order when gedcom imported

Posted: 12 Oct 2019 08:18
by Jane
P.S If you have not already check out the plugins:index#developer_guide|> Developer Guide on the Knowledge base

Re: Media order when gedcom imported

Posted: 12 Oct 2019 08:36
by tatewise
To loop through media use:

Code: Select all

	local ptrObjFirst = fhGetItemPtr(pi,'~.OBJE[1]')   	 -- Get first Media object
	local ptrObje = fhNewItemPtr()
	ptrObje:MoveTo(ptrObjFirst)
	while ptrObje:IsNotNull() do   	   	-- Loop through all Media objects
	   	local ptrPrim = fhGetItemPtr(ptrObj,'~._PRIM')
		if ptrPrim:IsNotNull() do   	-- if _PRIM tag exists move this Media object before first
	   		local bOK = fhMoveItemBefore(ptrObj,ptrObjFirst)
	   		local bOK = fhDeleteItem(ptrPrim)   	-- Delete _PRIM UDF tag
	   		break   	   	-- Job done so escape from loop
	   	end
	   	ptrObje:MoveNext()
	end

Re: Media order when gedcom imported

Posted: 13 Oct 2019 08:24
by pmolnar
Hi Mike, Jane,

I managed to create what I wanted to do, many thanks for the help, it works fine.

Regards,
Peter