I need to deploy different images into picture library for different sub sites in a single feature, I mean I have five images, I need to deploy the first two image in the site collection, third image in subsite as well as last two images in another two subsites. I am not sure is this possible.I think we can achieve this by XML and c#. Please suggest me some best practices.
Don't do this by XML declarative code, but use a feature event receiver to implement anything you want with C# code:
With the feature ER code, you can easily leverage the server-side API to connect to the root site of the site collection (assuming the feature is site-scoped, i.e. site collection) and any sub-site you want (the clever approach being to create those sub-sites as well when the feature is activated, so you know their URL).
If you have an
ElementFile as part of your feature, you can get access to it when the feature is deployed, from the ER code: simply get the
properties.Definition.RootDirectory and build the complete path of the file you want to read. Then, use the simple and well-known API calls to upload the file wherever you want in SharePoint.