* Media order when gedcom imported

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile
Post Reply
avatar
pmolnar
Gold
Posts: 11
Joined: 20 Aug 2011 17:56
Family Historian: V6.2

Media order when gedcom imported

Post by pmolnar » 11 Oct 2019 13:11

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
Attachments
screenshot.png
screehsot of person's media
screenshot.png (33.6 KiB) Viewed 381 times

User avatar
LornaCraig
Megastar
Posts: 1536
Joined: 11 Jan 2005 17:36
Family Historian: V6.2
Location: Oxfordshire, UK

Re: Media order when gedcom imported

Post by LornaCraig » 11 Oct 2019 13:23

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 372 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 372 times
Lorna

User avatar
Jane
Site Admin
Posts: 7727
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Media order when gedcom imported

Post by Jane » 11 Oct 2019 13:25

_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.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
tatewise
Megastar
Posts: 16462
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Media order when gedcom imported

Post by tatewise » 11 Oct 2019 15:15

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 Knowledge Base > Handling Uncategorised Data Fields (UDF).
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
pmolnar
Gold
Posts: 11
Joined: 20 Aug 2011 17:56
Family Historian: V6.2

Re: Media order when gedcom imported

Post by pmolnar » 11 Oct 2019 17:29

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?

avatar
pmolnar
Gold
Posts: 11
Joined: 20 Aug 2011 17:56
Family Historian: V6.2

Re: Media order when gedcom imported

Post by pmolnar » 12 Oct 2019 04:48

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.

User avatar
Jane
Site Admin
Posts: 7727
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Media order when gedcom imported

Post by Jane » 12 Oct 2019 08:16

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)
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
Jane
Site Admin
Posts: 7727
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: Media order when gedcom imported

Post by Jane » 12 Oct 2019 08:18

P.S If you have not already check out the Knowledge Base > Developer Guide on the Knowledge base
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
tatewise
Megastar
Posts: 16462
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Media order when gedcom imported

Post by tatewise » 12 Oct 2019 08:36

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
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
pmolnar
Gold
Posts: 11
Joined: 20 Aug 2011 17:56
Family Historian: V6.2

Re: Media order when gedcom imported

Post by pmolnar » 13 Oct 2019 08:24

Hi Mike, Jane,

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

Regards,
Peter

Post Reply